error when npm install: ERR! cb() never called! npm ERR! This is an error with npm itself, it has been resolved

created at 08-08-2021 views: 247

Error details

Whenn run npm install, got error:

npm ERR! cb() never called! 
npm ERR! This is an error with npm itself. Please report this error at:
...

I tried this problem for several days and found a lot of methods, but they were all unsuccessful. Finally, I combined many methods to solve it.
Record my solution here, so that you can solve this problem in the future:

reason

I found a lot of methods for this problem on the Internet, and then I tried it. Then, in my opinion, my npm version may be too low, or when downloading dependencies, the Internet speed is too slow and it has been stuck, and finally an error is reported. These are just what I think

Solution

  1. Find the project with the download dependency error, and then delete the downloaded nodel_module folder and the downloaded dependency package under the folder
  2. If there is a package.lock.json file, it also needs to be deleted, if there is no such file, don’t delete it.
  3. Upgrade your own machine's npm, enter the command in the cmd window:
npm install npm -g

The following command lines are executed here at the same time (or not executed):

npm install  -g webpack

4. Clear the cache and execute the command in the terminal window of the project

npm cache clean --force

The results are as follows:

clean cache of npm

5. Re-download dependencies,
Excuting an order:

npm install

If this command fails, repeat the above steps, and then use cnpm to install
Install cnpm:

npm install cnpm -g

Then execute cnpm to download the dependencies:

cnpm install

result:

cnpm install

installed successfully

Although there are some red flags here, there is no error, it is okay, and the project can be started later

npm run dev

problem solved!

created at:08-08-2021
edited at: 08-08-2021: