npm ERR! cb() never called! error when trying to r

2020-02-02 01:49发布

问题:

I have this react-native project I worked on my other pc, and I want now to keep working on this exact project folder in my other linux machine.

So now I have the project folder, which doesn't contain node_modules directory, but it does contain "package.json". As I understood it, doing NPM install inside the directory, should install and create the node_modules directory with all the needed dependencies. However, the operation is failed after a while with the error "npm ERR! cb() never called!"

I've already tried to clean npm cache (with -f flag) but it doesn't worked for me. I'm running on Ubuntu 18.04 based os with Node.js v8.10.0 and npm v3.5.2.

回答1:

In my case, I had an own custom node_module which is in my package.json like that:

// ...
"dependencies": {
    // ...
    "my-module": "file:../../my-module",
},
// ...

This package is only available in a specific environment (dynamically added to package.json via npm install ../../my-module), which is by intend, but I forgot about it and when I ran npm install in another environment (where my module was not available) the mysteriuos cb() never called error occured.

After putting the option --no-package-lock behind the npm install the error got more clear, telling me that it has something to do with my-module.

see also: https://stackoverflow.com/a/52474959/3063191

Hope this helps :)



回答2:

I had similar issue for git project. Actually project configuration has created bad .npmrc  file, which was preventing package installation. so i deleted .npmrc file and took below steps in sequence
   1) Deleted node_modules from project, if any
   2) Deleted temp files from machine 
   3) Execute npm cache clean --force
   4) Do npm install


标签: node.js npm