每当我在终端中运行webpack
时,都会收到以下信息:
Hash: efea76b1048c3a97b963
Version: webpack 1.12.13
Time: 33ms
+ 1 hidden modules
ERROR in Cannot find module 'babel-core'
这是我的webpack.config.js文件
module.exports = {
entry: './app-client.js',
output: {
filename: 'public/bundle.js'
},
module: {
loaders: [
{
exclude: /(node_modules|app-server.js)/,
loader: 'babel'
}
]
}
}
package.json
{
"name": "react",
"version": "1.0.0",
"description": "React polling app",
"main": "app-client.js",
"dependencies": {
"babel-loader": "^6.2.2",
"bootstrap": "^3.3.6",
"express": "^4.13.4",
"react": "^0.14.7"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
packag.json
中,以避免再次遇到这个问题。使用-S
标志运行npm install
就可以完成任务了。 - andilabsError: Cannot find module '@babel/core'。 babel-loader@8需要Babel 7.x(包'@babel/core'),如果你想使用Babel 6.x('babel-core'包), 你应该安装'babel-loader@7'。
- pguardiariobeta
版本,这似乎是维护者的疏忽。我手动指定了babel-loader
的7.1.5
版本(当前最新版本),现在已经正常运行。 - Brian Underwood