[Solved] Vue Project Error: Error: Cannot find module ‘webpack‘ Require stack以及Error: Rule can only have one resource so

Error 1: NPM run serve reports an error when Vue project is started: error: cannot find module ‘webpack’ require stack

After the project is pulled down and the dependencies are installed normally, start the project and report error: cannot find module ‘webpack’ require stack. It is found that the webpack module is missing,

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)

However, I have already installed webpack. Here, I need to re open CMD to install webpack globally

reason:

even if you installed webpack before, it must be a non global installation

Solution:

npm install  -g webpack

After the installation is complete, I start the project and find that it reports an error again!
Reported error: Error: Rule can only have one resource source (provided resource and test + include + exclude) in


Error 2: Project Error: 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
  ]

reason:

package. Webpack version conflict in JSON

Solution::

delete the webpack and reinstall the previous version

npm uninstall webpack
npm install webpack@^4.0.0 --save-dev

Read More: