After pulling the project, an error is reported Error: Cannot find module 'webpack'

Because "this is a bug in the new version of webpack , just uninstall the existing new version of webpack and install the old version."
1. Uninstall: npm uninstall webpack-dev-server
2. Install the corresponding version: npm install webpack-dev-server@ 2.9.6

After following the method steps, the error still exists.

Cause Analysis:

After troubleshooting, it was found to be a problem with the npm version. Execute npm -v to find that the version is 8.1. The latest version of npm is affected by incomplete dependencies on packages. After npm dropped to version 6, the problem was solved.

solution:

  1. First delete the node_modules in the project
  2. Uninstall the original npm
npm uninstall npm -g
  1. Install the specified version
npm install npm@6 -g

Complete the operation, execute the npm run dev command, and the problem is solved.

Solution 2:

Use nvm to change node version

Guess you like

Origin blog.csdn.net/m0_59338367/article/details/129620732