请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

babel-core babel-preset-env出错

package.json中代码
{
“name”: “3-5”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“keywords”: [],
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“babel-core”: “^6.26.3”,
“babel-loader”: “^7.1.5”,
“babel-plugin-lodash”: “^3.3.4”,
“babel-preset-env”: “^1.7.0”,
“css-loader”: “^2.0.0”,
“extract-text-webpack-plugin”: “^3.0.2”,
“file-loader”: “^2.0.0”,
“less”: “^3.9.0”,
“less-loader”: “^4.1.0”,
“node-sass”: “^4.11.0”,
“postcss-loader”: “^3.0.0”,
“sass-loader”: “^7.1.0”,
“style-loader”: “^0.23.1”,
“webpack”: “^3.12.0”,
“webpack-cli”: “^2.1.5”
},
“dependencies”: {
“lodash”: “^4.17.11”,
“lodash-es”: “^4.17.11”
}
}

webpack.config.js中代码
const path=require(‘path’)
const ExtractTextWebpackPlugin=require(‘extract-text-webpack-plugin’);
const webpack=require(‘webpack’);
module.exports={
entry:{
app:’./src/app.js’
},
output: {
path:path.resolve(__dirname,‘dist’),
publicPath: ‘./dist/’,
filename: ‘[name].bundle.js’,
chunkFilename: ‘[name].chunk.js’
},
module: {
rules: [
{
test:/.lessKaTeX parse error: Expected 'EOF', got '}' at position 607: …}) }̲, {…/,
use:[{
loader:‘babel-loader’,
options:{
presets:[‘env’],
plugins:[‘lodash’]
}
}]
}
]
},
plugins: [
new ExtractTextWebpackPlugin({
filename: ‘[name].min.css’,
allChunks:false
}),
new webpack.optimize.UglifyJsPlugin()
]
}
app.js中代码
import base from './css/base.less’
import common from ‘./css/common.less’

import {a} from './common/util’
import {chunk} from 'lodash-es’
console.log(chunk([1,2,3,4,5],2))
运行webpack 出现报错

ERROR in ./node_modules/css-loader/dist/runtime/api.js
Module build failed: Error: Couldn’t find preset “@babel/preset-env” relative to directory “C:\Users\Administrator\Desktop\
3-12\node_modules\css-loader”

老师,这是怎么回事啊

正在回答 回答被采纳积分+3

1回答

qbaty 2018-12-19 19:26:38

@babel/preset-env 你没有安装这个模块

npm i @babel/preset-env -D

然后 presets:['@babel/preset-env']


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信