问题一.vue项目启动时npm run serve报错:Error: Cannot find module ‘webpack’ Require stack
项目拉下来以后,正常安装完依赖,启动项目时报Error: Cannot find module ‘webpack’ Require stack,发现是缺少webpack模块,
Error: Cannot find module 'webpack'
Require stack:
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
- 1
- 2
- 3
- 4
- 5
但是我已经安装过webpack了,这里需要重新打开cmd,全局安装webpack
原因:
就算之前你装了webpack,那肯定是非全局安装
解决:
npm install -g webpack
- 1
安装完成以后,启动项目发现又报错了!!!
报错:Error: Rule can only have one resource source (provided resource and test + include + exclude) in
问题二:项目报错:Error: Rule can only have one resource source (provided resource and test + include + exclude) in
Error: Rule can only have one resource source (provided resource and test + include + exclude) in {
"exclude": [
null
]
- 1
- 2
- 3
- 4
原因:
package.json中webpack版本冲突问题。
解决:
删除webpack,重新装以前的版本。
npm uninstall webpack
npm install webpack@^4.0.0 --save-dev
- 1
- 2