我在npm开始时遇到此错误。 我尝试删除节点模块并再次执行npm install但是修复了问题
- 多个(webpack)-dev-server / client中的错误?http://localhost:8080 ./ main.js
找不到模块:错误:无法解决' babel'在' *****'
@ multi(webpack)-dev-server / client?http://localhost:8080 ./main.js
- 醇>
webpack:无法编译
This is my webpack.config
module.exports = {
entry : './main.js',
output: {
path: '/',
filename: 'index.js'
},
devServer: {
inline: true,
port: 8083
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015','react']
}
}
]
}
}
This is my package.json
{
"name": "proj3",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"webpack": "^3.4.1",
"webpack-dev-server": "^2.6.1"
}
}
答案 0 :(得分:1)
您需要将Babel软件包添加到项目中,因为它会转换ES6代码(反应)。
这是包裹。
babel-loader
babel-core
babel-preset-es2015
babel-preset-react