使用vue.js常见错误之一

打包项目时,在vscode中输入如下命令

webpack .\src\main.js .\dist\bundle.js

出现如下错误:

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/main.js ./dist/bundle.js
Module not found: Error: Can't resolve '.\dist\bundle.js' in 'E:\Vue相关练习\webpack-study'
@ multi ./src/main.js ./dist/bundle.js main[1]

因为这是老版本,而在webpack4之后 官方对 webpack-cli 单独抽离了出来 所以我们需要做如下步骤方可成功

1. 安装webpack

npm i webpack -g
2. 安装 cli

npm i -g webpack-cli
3. 打包 将 main.js bundle.js 替换了就可以

npx webpack main.js --output-filename bundle.js  --output-path . --mode development

posted on 2019-03-16 22:50  开发中123  阅读(237)  评论(0编辑  收藏  举报

导航