我在我的项目中安装了webpack
和webpack-cli
:
"devDependencies": {
"webpack": "^4.8.3",
"webpack-cli": "^2.1.3"
}
但是,当我使用webpack-cli
打包dist/app.bundle.js
时,我得到了以下错误:
$ node_modules/.bin/webpack-cli src/app.js dist/app.bundle.js
Hash: a7d5a0d1ff2c17795899
Version: webpack 4.8.3
Time: 139ms
Built at: 2018-05-14 11:53:07
1 asset
Entrypoint main = main.js
[0] ./src/app.js 28 bytes {0} [built]
[1] multi ./src/app.js dist/app.bundle.js 40 bytes {0} [built]
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/
ERROR in multi ./src/app.js dist/app.bundle.js
Module not found: Error: Can't resolve 'dist/app.bundle.js' in '/Users/lll/Desktop/VueTest/hello-world'
@ multi ./src/app.js dist/app.bundle.js
答案 0 :(得分:5)
在webpack 4
中,您应该为命令添加参数:
node_modules/.bin/webpack-cli src/app.js --output dist/app.bundle.js --mode development
添加--output
参数,您的问题将得到解决。
您还可以查看webpack output path。