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:
- First delete the node_modules in the project
- Uninstall the original npm
npm uninstall npm -g
- 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