453

I have a Node.js app hosted on Heroku. Every time I do a git push heroku I get the following error:

Counting objects: 14, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.20 KiB, done.
Total 12 (delta 8), reused 0 (delta 0)

-----> Node.js app detected
-----> Resolving engine versions
       Using Node.js version: 0.6.20
       Using npm version: 1.2.12
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       npm http GET https://registry.npmjs.org/pg/0.6.15
       npm http GET https://registry.npmjs.org/socket.io
       npm http 200 https://registry.npmjs.org/pg/0.6.15
       npm http GET https://registry.npmjs.org/pg/-/pg-0.6.15.tgz
       npm http 200 https://registry.npmjs.org/socket.io
       npm http GET https://registry.npmjs.org/socket.io/-/socket.io-0.9.13.tgz
       npm http 200 https://registry.npmjs.org/pg/-/pg-0.6.15.tgz
       npm http 200 https://registry.npmjs.org/socket.io/-/socket.io-0.9.13.tgz
       npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
       npm http GET https://registry.npmjs.org/policyfile/0.0.4
       npm http GET https://registry.npmjs.org/base64id/0.1.0
       npm http GET https://registry.npmjs.org/redis/0.7.3
       npm http GET https://registry.npmjs.org/generic-pool/1.0.9
       npm http 200 https://registry.npmjs.org/policyfile/0.0.4
       npm http GET https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz

       npm http 200 https://registry.npmjs.org/base64id/0.1.0
       npm http GET https://registry.npmjs.org/base64id/-/base64id-0.1.0.tgz
       npm http 200 https://registry.npmjs.org/generic-pool/1.0.9
       npm http GET https://registry.npmjs.org/generic-pool/-/generic-pool-1.0.9
.tgz
       npm http 200 https://registry.npmjs.org/socket.io-client/0.9.11
       npm http GET https://registry.npmjs.org/socket.io-client/-/socket.io-clie
nt-0.9.11.tgz
       npm http 200 https://registry.npmjs.org/redis/0.7.3
       npm http GET https://registry.npmjs.org/redis/-/redis-0.7.3.tgz
       npm http 200 https://registry.npmjs.org/policyfile/-/policyfile-0.0.4.tgz

       npm http 200 https://registry.npmjs.org/base64id/-/base64id-0.1.0.tgz
       npm http 200 https://registry.npmjs.org/generic-pool/-/generic-pool-1.0.9
.tgz
       npm http 200 https://registry.npmjs.org/socket.io-client/-/socket.io-clie
nt-0.9.11.tgz
       npm http 200 https://registry.npmjs.org/redis/-/redis-0.7.3.tgz

       > pg@0.6.15 install /tmp/build_36us8733h7kkr/node_modules/pg
       > node-waf configure build || (exit 0)

       Checking for program g++ or c++          : /usr/bin/g++
       Checking for program cpp                 : /usr/bin/cpp
       Checking for program ar                  : /usr/bin/ar
       Checking for program ranlib              : /usr/bin/ranlib
       Checking for g++                         : ok
       Checking for node path                   : not found
       Checking for node prefix                 : ok /tmp/node-node-nNUw
       Checking for program pg_config           : /usr/bin/pg_config
       'configure' finished successfully (0.058s)
       Waf: Entering directory `/tmp/build_36us8733h7kkr/node_modules/pg/build'
       [1/2] cxx: src/binding.cc -> build/Release/src/binding_1.o
       [2/2] cxx_link: build/Release/src/binding_1.o -> build/Release/binding.no
de
       Waf: Leaving directory `/tmp/build_36us8733h7kkr/node_modules/pg/build'
       'build' finished successfully (0.492s)
       npm http GET https://registry.npmjs.org/uglify-js/1.2.5
       npm http GET https://registry.npmjs.org/ws
       npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
       npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
       npm http 200 https://registry.npmjs.org/active-x-obfuscator/0.0.1
       npm http GET https://registry.npmjs.org/active-x-obfuscator/-/active-x-ob
fuscator-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/uglify-js/1.2.5
       npm http GET https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
       npm http 200 https://registry.npmjs.org/xmlhttprequest/1.4.2
       npm http GET https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1
.4.2.tgz
       npm http 200 https://registry.npmjs.org/ws
       npm http GET https://registry.npmjs.org/ws/-/ws-0.4.25.tgz
       npm http 200 https://registry.npmjs.org/active-x-obfuscator/-/active-x-ob
fuscator-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
       npm http 200 https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1
.4.2.tgz
       npm http 200 https://registry.npmjs.org/ws/-/ws-0.4.25.tgz
       npm http GET https://registry.npmjs.org/zeparser/0.0.5
       npm http GET https://registry.npmjs.org/commander
       npm http GET https://registry.npmjs.org/tinycolor
       npm http GET https://registry.npmjs.org/options
       npm http 200 https://registry.npmjs.org/zeparser/0.0.5
       npm http GET https://registry.npmjs.org/zeparser/-/zeparser-0.0.5.tgz
       npm http 200 https://registry.npmjs.org/options
       npm http GET https://registry.npmjs.org/options/-/options-0.0.3.tgz
       npm http 200 https://registry.npmjs.org/tinycolor
       npm http GET https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/commander
       npm http GET https://registry.npmjs.org/commander/-/commander-0.6.1.tgz
       npm http 200 https://registry.npmjs.org/zeparser/-/zeparser-0.0.5.tgz
       npm http 200 https://registry.npmjs.org/options/-/options-0.0.3.tgz
       npm http 200 https://registry.npmjs.org/tinycolor/-/tinycolor-0.0.1.tgz
       npm http 200 https://registry.npmjs.org/commander/-/commander-0.6.1.tgz

       > ws@0.4.25 install /tmp/build_36us8733h7kkr/node_modules/socket.io/node_
modules/socket.io-client/node_modules/ws
       > (node-gyp rebuild 2> builderror.log) || (exit 0)

       make: Entering directory `/tmp/build_36us8733h7kkr/node_modules/socket.io
/node_modules/socket.io-client/node_modules/ws/build'
         CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
         SOLINK_MODULE(target) Release/obj.target/bufferutil.node
         SOLINK_MODULE(target) Release/obj.target/bufferutil.node: Finished
         COPY Release/bufferutil.node
         CXX(target) Release/obj.target/validation/src/validation.o
         SOLINK_MODULE(target) Release/obj.target/validation.node
         SOLINK_MODULE(target) Release/obj.target/validation.node: Finished
         COPY Release/validation.node
       make: Leaving directory `/tmp/build_36us8733h7kkr/node_modules/socket.io/
node_modules/socket.io-client/node_modules/ws/build'
       npm ERR! cb() never called!
       npm ERR! not ok code undefined
       npm ERR! cb() never called!
       npm ERR! not ok code 1
 !     Failed to install --production dependencies with npm
 !     Heroku push rejected, failed to compile Node.js app

To git@heroku.com:still-chamber-1286.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:still-chamber-1286.git'

The error is in the last few lines:

npm ERR! cb() never called!
           npm ERR! not ok code undefined
           npm ERR! cb() never called!
           npm ERR! not ok code 1
     !     Failed to install --production dependencies with npm
     !     Heroku push rejected, failed to compile Node.js app

    To git@heroku.com:still-chamber-1286.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'git@heroku.com:still-chamber-1286.git'

I have had no problems with pushing my code to Heroku before; only since Monday have I had this error.

I have seen similar posts on the web referring to slightly different errors, but haven't seen one with ! [remote rejected] master -> master (pre-receive hook declined) before.

Christian Fritz
  • 20,641
  • 3
  • 42
  • 71
Louise K
  • 4,741
  • 3
  • 16
  • 17
  • I'm getting the same error when pushing my node app to heroku today: `! [remote rejected] master -> master (pre-receive hook declined)` – smithclay Mar 13 '13 at 18:59
  • 6
    Strangely, adding `"engines": { "node": "0.8.x" }` to my `package.json` fixed that error for me. – smithclay Mar 13 '13 at 20:16
  • It worked, thanks a lot :) Although it should be noted that I already had `"engines": { "node": "0.6.x" }` in `package.json`, I simply had to change it from `0.6.x` to `0.8.x` – Louise K Mar 14 '13 at 14:04
  • 1
    There is currently an open issue about this error with npm and node 0.10.0: https://github.com/isaacs/npm/issues/2907 – jonathancardoso Mar 15 '13 at 12:49
  • 2
    I fixed this for myself by simply updating npm ( `$> npm install -g npm` )since I was getting warnings that packages expected a higher version of it anyways in the console output. – racl101 Oct 02 '15 at 15:14
  • made a PR to start a troubleshooting doc on this: https://github.com/npm/npm/pull/21005 – Ben Creasy Jun 17 '18 at 07:19
  • avoid using sudo with npm. If you get errors check if any directories are owned by root in your npm cache dir (~/.npm on ubuntu) if they are delete them and it should start afresh and have no errors on your next `npm install` command. – Paul Rooney Jan 24 '19 at 23:41
  • i had fixed same issue. see this link https://stackoverflow.com/questions/52467848/npm-err-cb-never-called-error-when-trying-to-run-npm-install-command/58089750#58089750 – kumar chandraketu Sep 25 '19 at 00:52

61 Answers61

461

If you have npm version 5 or above, try this first:

$ sudo npm cache verify

Otherwise:

$ sudo npm cache clean

My node and npm versions are:

$ node -v
v0.10.0

$ npm -v
1.2.14

https://docs.npmjs.com/cli/cache

MAZux
  • 911
  • 1
  • 15
  • 28
Alberto
  • 4,787
  • 1
  • 13
  • 6
  • 1
    Workaround helped, but for the same error but during module installation (grunt-contrib-yuidoc), thanks. – Wiseman Jul 22 '13 at 13:39
  • Isn't this solution for local runs and not on Heroku? For Heroku this solution seems does not work. – Valentyn Shybanov Sep 26 '13 at 22:57
  • Got this error after building a postgres native extension, rm -fr $HOME/.node-gyp do the trick. – Giovanni Toraldo Jul 24 '14 at 09:20
  • I got the error when trying to install cordova. I did the cache clean method and tried the install again and it worked. Thanks alot. – Ads Oct 09 '14 at 23:34
  • See also [nmp cache location](http://stackoverflow.com/questions/19874582/change-default-global-installation-directory-for-node-js-modules-in-windows) in general and [under system account on windows](http://stackoverflow.com/questions/31342624/teamcity-with-npm-error-enoent-stat-c-windows-system32-config-systemprofil). – Vadzim May 18 '16 at 15:06
  • As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead. – Ivan Rave Jun 26 '17 at 10:32
  • Heard a lot of folks say its better to install and use NPM without sudo and it has been working well for me since I stopped – light24bulbs Apr 20 '18 at 13:57
  • you need to hit, sudo npm cache clean --force – Rahul Dudhane Jun 30 '20 at 14:38
  • `npm cache clean` doesn't work anymore from npm 5 and above as is considered self healing – eKelvin Mar 03 '21 at 08:58
  • I got this error when I clone my personal repo and did a npm install. $ npm install npm ERR! cb() never called! npm ERR! This is an error with npm itself. Please report this error at: npm ERR! Running sudo npm cache verify worked for me in this answer – utkarsh-k Mar 21 '21 at 08:52
144

For anyone hitting this page around Sept 29th, 2013, there's a closed bug in Node.js 0.10.19 which is causing this error.

https://github.com/isaacs/npm/issues/2907#issuecomment-15215278 https://github.com/joyent/node/issues/6263#issuecomment-25113849

If you're on Heroku you should upgrade to 0.10.20

"engines": {
    "node": "0.10.20"
}
Thomas Grainger
  • 2,271
  • 27
  • 34
mdp
  • 1,413
  • 1
  • 9
  • 8
  • Thanks. I am trying to build rippled and ran into this exact error. Your answer helped. (Note: it seems that re-running the command multiple times eventually gets it to succeed. In my case it was "npm install") – DV. Sep 26 '13 at 20:23
  • Having the same problem. (npm ERR! cb() never called!) running Node 0.1.19/NPM 1.3.11. Im trying to install cordova with "sudo npm install -g cordova" – Fredric Berling Sep 26 '13 at 20:48
  • Not sure if it applies. But when trying to install (wintersmith) with `-g` it failed with this error. If I first installed without the global option, and then installed with it, I did not get the error. – Chris Rockwell Sep 27 '13 at 01:03
  • 1
    I had this very error yesterday, and re-installed node today (Oct 1st) and it's working again - it seems to be fixed in v0.10.20. Thanks for this thread, saved me a lot of time. – dirkk0 Oct 01 '13 at 05:24
  • I had the same error in v0.10.36. Updated to v0.12.3 and fixed. – cespon May 17 '15 at 11:02
  • It is still a bug in 2021. – Obaid Jun 26 '21 at 20:59
82

Try

sudo npm cache clean --force

More info refer: https://reactgo.com/npm-err-cb-never-called/

Marwan Salim
  • 682
  • 7
  • 14
SanS
  • 1,137
  • 9
  • 7
  • To anyone trying this, I was doing this in my local Angular project directory (VS code terminal) and 'sudo' did not work. However, using just `npm cache clean --force` worked for me in my local instance and resolved this error message. Thanks! – Kyle Vassella Aug 10 '20 at 21:07
  • 1
    Still working fine as of end 2021 – Marco Faustinelli Nov 03 '21 at 11:03
41

If you have updated angular cli, npm, node, you don't need to do anything more. Just run the command below to resolve the issue. This command also resolves the issue of "unexpected end of line".

npm install --no-package-lock
Cristik
  • 30,989
  • 25
  • 91
  • 127
chetan shah
  • 511
  • 4
  • 4
31

IMPORTANT! The solution below is now regarded as unstable, and you should use Node Version Management instead: Node Version Manager on Github. David Walsh also has a good introduction to NVM. NVM works beautifully and I've been using it to manage legacy WordPress projects for a few years.


Please don't use this - use NVM

I just had this exactly issue when trying to install the Sage theme for WordPress. When I ran npm install on the theme directory, it failed.

Looking in the dependencies in package.json, I could see that the engine I was running for Node was out of date. Running node -v on the command line showed that I was on v0.10.9, and the latest version of Sage requires >= 0.12.0

So here's the fix for that. These steps are from David Walsh's blog

  1. Clear your npm cache: sudo npm cache clean -f
  2. Install the latest version of the Node helper: sudo npm install -g n
  3. Tell the helper (n) to install the latest stable version of Node: sudo n stable

You should then get a progress display, after which you will be up to date.

When I ran npm install after doing this, everything worked fine, and I was able to run gulp to build the initial dist directory.

codewithfeeling
  • 6,236
  • 6
  • 41
  • 53
  • 2
    Step 2 should be `sudo npm install -g n` as well. – Mauro Vanetti Mar 12 '18 at 09:52
  • According to your source link, this solution is "unstable" and Node Version Manager is better https://github.com/nvm-sh/nvm/blob/master/README.md – PJ Brunet Mar 29 '20 at 07:55
  • NVM only works on Linux and my company's policy will not let me install the Windows version. So, I have to uninstall and reinstall every single time. Yay! – Jordan Apr 04 '23 at 21:11
24

Do you have a specific version of "npm" specified under "engines" in your package.json? Sounds like NPM v1.2.15 resolved the issue (and Heroku has available). I was getting the same problem with "1.1.x".

Aidan Feldman
  • 5,205
  • 36
  • 46
  • Fantastic. That was bugging me for sure. Specified my npm version and it worked like a charm. – Eric H. Jul 04 '13 at 01:46
  • 44
    IF YOU ARE EVER IN AUSTIN,TX, PLEASE LET ME BUY YOU A PIZZA! I'm sorry for the all caps, but it captures my current state of joy as a result of your answer. I would never have suspected that having that version specification for NPM was the culprit. Aidan, I hope you have a wonderful day. – juanpaco Jul 25 '13 at 14:01
  • 1
    @juanpaco, you are too funny. – Daniel Sep 16 '19 at 22:14
  • Yeach I remove this "engines" sheet from package.json and it works :) – Kamil Kiełczewski Oct 09 '19 at 19:24
21
  • Run npm install -g npm
  • Then run npm install
Shujat Munawar
  • 1,657
  • 19
  • 23
16

Updating the NodeJS https://nodejs.org/en/ Fixed My Issue.

Run npm install -g npm & npm cache clean

Srinivas
  • 847
  • 11
  • 13
16

For me none of the above solutions worked (reinstalling, clearing cache, folders etc.).

My problem was solved with:

npm config set registry https://registry.npmjs.org/
Bubiec
  • 363
  • 2
  • 10
14

Since NPM 6 you can do a clean install.
That was the only solution which worked for me.

Just run the following:

npm clean-install

Notes:

  • You might also manually remove the node_modules folder and try again in case the command above failed.
  • If still doesn't work, the global cache might be broken, try running npm cache clean --force and then do a clean install.
  • The clean-install command works on npm 6 and above. For older versions consider checking the other answers below.
Just Shadow
  • 10,860
  • 6
  • 57
  • 75
12

I had the same problem while installing ionic@beta. I tried the following items and they didn't help me.

  1. npm cache clean
  2. Manually delete cache from %temp%\npm-*
  3. Command prompt "Run As Administrator"

I solved the problem by installing node-v5.10.1-x64.msi (Previous version was node-v5.9.0-x64.msi) and run an npm cache clean before installing ionic@beta

It worked!

Sen Jacob
  • 3,384
  • 3
  • 35
  • 61
12

UPDATED: The problem is pretty common here is the new fix npm cache verify run that you will be good to go!

James Christian Kaguo
  • 1,251
  • 15
  • 14
11

[Works] try

npm config delete https-proxy

it would have conflicted with proxy.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
KrtkNyk
  • 141
  • 1
  • 4
9

I had the same problem with NPM version 1.3.11, and solved it simply by re-running the exact same command multiple times ("npm update -g" in my case). The error popped up for a different package on each subsequent run and eventually everything updated successfully.

For me at least, it seems like it was being caused by a network issue (corrupted downloads). I was also getting an error about an invalid package, which I was able to resolve by deleting all instances of "tmp.tgz".

Edit: (Probably unrelated, but in case this helps anyone: I was using Windows, and started a command prompt as an Administrator after receiving the initial error).

Sven Viking
  • 2,660
  • 21
  • 34
  • 1
    Since posting this I've seen a lot of people saying they've had the same experience on Unix and Mac (multiple attempts eventually bypass the issue). Don't know if the problem is networking related or not, but it seems widespread. – Sven Viking Sep 27 '13 at 06:58
  • Apparently this bug is now fixed in v0.10.20: http://blog.nodejs.org/2013/09/30/node-v0-10-20-stable/ – Sven Viking Oct 01 '13 at 07:05
8

I had the cb() never called! error, and none of the answers here directly worked for me. I was running Node v8.11.2, and I had to manually delete the package-lock.json file to get anywhere. After doing this, I ran npm cache verify per what some of the answers recommended. Then, running npm i yielded the following result:

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN securities-stub@1.0.0 No description
npm WARN securities-stub@1.0.0 No repository field.

up to date in 5.118s
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
8

If the bug persists even after running npm cache clean --force, try to rerun npx create-react-app your_app_name after switching to a different network. This error could also cause due to slow and unstable networks...

7

As of March 2021 the new NPM version fixes many of those issues.

So calling npm i -g npm@latest fixes this again (In between this did not work).

Obiwahn
  • 2,677
  • 2
  • 26
  • 36
6

I just globally installed the newest version of NPM and it worked for me. I guess Clearing npm cache is optional.

npm install -g npm
Akash Tantri
  • 948
  • 9
  • 15
6

For me on npm 6.4.0 and node 10.9.0 none of the answers worked. Reinstalled node, npm, cleaned cache, removed folders ...

After some debugging it turned out I used npm link for two of my modules under development to link to each other. Once I removed and redid some linking I was able to get it all working again.

Flion
  • 10,468
  • 13
  • 48
  • 68
6

Knowing that this is an old question and many of you had provided your answers. Just to share my experience with this error and how I fixed.

This all started after I upgrade my Node version to > 12, I did go through all the answers and try to follow steps clearing npm Cache, deleting the node_modules folder. No one of them resolve my problem.

The root cause in my case was proxy restricting installation. I deleted the proxy settings to fix the problem.

  1. Check if you have any proxy config

    npm config list
    
  2. Delete them by

    npm config delete proxy
    npm config delete http-proxy
    npm config delete https-proxy
    
  3. Now try

    npm install
    
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Prakash
  • 111
  • 1
  • 6
6

What worked for me was: delete the package-lock.json file and run the following command:

npm cache clean --force

joe hoeller
  • 1,248
  • 12
  • 22
5

sudo npm cache clean didn't work out for me. Update to the latest version of node helps.

I had node v.5.91 and updated to v6.9.1

h--n
  • 5,903
  • 4
  • 31
  • 32
5

I suggest: Switch to Yarn! - Yarn is a package manager which uses the same package.json file and node_modules folder as npm.

With npm I had the same problem: On a CentOS 6 install I got the ERR cb() never called error repeatedly and could not find a way to make npm reliably complete installation of some packages (like webpack for example). - Yarn works flawlessly, even on flaky network connections.

Migration to Yarn is easy. Most subcommands are the same. They have a good Migration guide. Read on to the handy CLI commands comparison at the end.

halloleo
  • 9,216
  • 13
  • 64
  • 122
  • I've often had problems with `npm install` inside a Docker container (typically running on an Ubuntu host). `yarn install` has unblocked me in two different projects when `npm install` has failed! Wish I could know why, however... – Jamie Birch Apr 04 '19 at 16:00
  • Yes, I can confirm I had no problems with Yarn. Unfortunately npm is a crap nowadays. Package lock file generation is broken in some random moments. Nothing like that happens in Yarn. Its yarn.lock file is always fine – Nickon Mar 19 '20 at 15:51
5

For Ubuntu Users, the given below method worked for me.

Firstly, perform this : sudo npm cache verify

Then go to Home->.npm and delete the _cache folder by : sudo rm -rf _cacache/

go and check, maybe you found the solution.

Jaymeen_JK
  • 322
  • 4
  • 5
5

I have the same error in my project. I am working on isolated intranet so my solution was following:

  • run npm clean cache --force
  • delete package-lock.json
  • in my case I had to setup NPM proxy in .npmrc
Kacpers
  • 173
  • 3
  • 6
5

Try switching your network, somehow switching network worked for me.

I have tried many things mentioned in other answers, like:

  1. npm cache clean --force
  2. Delete existing node_modules, delete package-lock.json, and reinstall using - npm i
  3. npm cache verify
  4. npm clean-install

None of the above worked for me, might work for you. Try your luck.

SUMIT JAIN
  • 91
  • 1
  • 3
4

It appears that particular dependency versions can cause this issue. For example, gulp-uglifycss 1.0.7 has this problem (see https://github.com/rezzza/gulp-uglifycss/issues/15).

If you are allowing major or minor version updates in your packages.json via ^ or ~, remove those characters thoughout the file and try another npm install. If it works that time then you'll be alright after you have the fun of narrowing down which package is causing the problem.

Robert Johnson
  • 632
  • 6
  • 25
4

I had the same issue while trying to install firebase-tools in my windows laptop. this is how i solved it.

  1. I downloaded kaspersky and installed it. then i disabled kaspersky secure connections
  2. i opened cmd and run this command npm cache clean --force
  3. i then run this command npm install npm@latest -g
  4. i then run the firebase cli command npm install -g firebase-tools
Benja
  • 91
  • 3
  • in this command `npm cache clean --force` **--force** helped to clean cache – WasiF Aug 03 '18 at 18:18
  • @Benja - Kaspersky is an anti virus and it has nothing to do in your installation or issues of NPM. if you have issues with that, at max it can be for Proxy settings , or for any one of the reasons mentioned here – Ritumoni Sharma Oct 16 '19 at 14:22
4

I too faced the same problem today as I force stopped the npm package download in between due to internet issues.

I tried various things like,

  1. Running sudo npm cache clean -f - which did not work as expected
  2. Clean uninstalling node and reinstalling it - which as well didn't work

I finally tried to delete the folder containing the npm cache that was creating the problem. I ran the following command,

sudo rm -rf /Users/{user_system_user}/.npm/

Then I tried installing the package that was stuck and everything worked like a charm.

P.S: replace {user_sytem_user} according to the current user of your system.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Sulokit
  • 137
  • 3
4

If you are open your code in a IDE such as IntelliJ idea Close it and re try

3

Do npm install npm@latest -g to update npm to the latest version. This fixed the problem for me. I did do npm cache clean first

3

npm install would result in:

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

In my case, this error started happening when I upgraded to Node.js version 8.11.1. Previously using Node.js version 6.12.x and NPM version 5.8.0.

In addition to that, my test scripts would not find AVA:

sh: ava: command not found
npm ERR! Test failed.  See above for more details.

The solution was to downgrade NPM to 5.7.1

rafaCode
  • 121
  • 5
3

For anyone who has upgraded recently from 6.x to 6.7.0.

Deleting the /Users/{YOUR USERNAME}/.npm folder solved my issues with npm install.

I also, ran some of these commands suggested by https://npm.community/t/crash-npm-err-cb-never-called/858/93?u=jasonfoglia

sudo npm cache clean -f
sudo npm install -g n

But I'm not sure which actually worked until I deleted the folder. So if you experience this issue and just delete the .npm folder fixing your issue please note that in the comments.

Jason Foglia
  • 2,414
  • 3
  • 27
  • 48
3

In my case i couldnt install a VueJS plugin and i had to:

Changing the ownership of files:

sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib
sudo chown -R $(whoami) /usr/local/bin

And then made sure to ahve latest npm:

npm install -g npm@latest

Then installed my plugin and in your case probably your command isntead.

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
FBC
  • 1,047
  • 8
  • 18
3

I tried many things from internet. Only below method worked for me. If every answer in this question don't work, try below steps in below order. Note :

  • Reboots required
  • Use cmd to execute code (VSCode didn't worked for me)
  1. Delete local node module folder
  2. Delete local package-lock file
  3. Uninstall node.js
  4. Reboot
  5. Delete the folders: "C:\Users\ YOUR LOGIN NAME \AppData\Roaming\npm" and "C:\Users\ YOUR LOGIN NAME \AppData\Roaming\npm-cache"
  6. Look for other npm folders under AppData and delete them too.
  7. Reboot
  8. Reinstall node.js
  9. Reboot
  10. npm cache clean --force
  11. npm cache verify
  12. npm install --force
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Tharuka Madumal
  • 201
  • 2
  • 5
3

What helped me get over that error - cb() never called... is downgrading my NPM version. I had version 6.14.9, and I downgraded to version 6.14.6 by typing:

    npm install -g npm@6.14.6

note: nothing seemed to help. I tried many of the suggested solutions, including "npm cache clean" or uninstalling NPM and reinstalling.

Niv
  • 41
  • 3
  • For those who are still struggling with this problem and have not yet found a solution, maybe this link will help them. https://stackoverflow.com/questions/40461439/error-installing-sqlite3-in-node-js/65329644#65329644 – Shamshirsaz.Navid Dec 16 '20 at 19:12
  • I’m using NPM v6.14.11 and deleting `package-lock.json` worked just fine - don’t worry `package-lock.json` will be generated again. – S. Esteves Jan 10 '21 at 02:23
  • Holy moly. For whatever reason, this is the only solution that worked for me. I really don't know why. The npm log said nothing besides `cb() never called....` I had npm@6.14.17. After downgrading to v6.14.6, running `npm i` I installed npm@6.14.17 again, run `npm i` again and now it works with v6.14.17 too... – Ruben Jan 24 '23 at 15:20
2

Picking up where mdp left, the problem is with node 0.10.19 and npm 1.3.11

I found the easiest way to manage the downgrade to keep things going smoothly to be NVM, here is a nice tutorial on how to use it. I had my server environment modified and running correctly downgrading from 0.10.19 to 0.10.18 in a matter of minutes with NVM.

Joe Minichino
  • 2,793
  • 20
  • 20
  • NVM is very useful. I had so many issues with version conflicts and these were resolved only by installing and using NVM. It's awesome! Thanks. – Ken J Nov 25 '14 at 03:17
2

There may be two possibilities=>

  1. Try to update your node js and npm.

  2. Permission issue => a. Move your solution on c drive in your respective user account b. Need to run bash or cmd as administrator.

Hope this will resolve your issue

BWA
  • 5,672
  • 7
  • 34
  • 45
sachin
  • 222
  • 2
  • 3
2

I encountered the same problem on my Mac and I have tried all methods I can find: upgrade to latest Node, clean cache, remove _node_mudules_ directory, but all have no effect. Eventually, I believed it was the problem of Node environment, so I degraded my Node to an old LTS version 6.14.1, then the problem disappeared. This is what I do:

  1. Install NVM (To get a brand new isolated node environment, you'd better use NVM to manage your multiple Node environments, go to here for details)

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash

  2. Install Node.js 6.14.1

    nvm install 6.14.1

  3. Switch to the specific Node environment you install above

    nvm use 6.14.1

  4. Install create-react-app

    npm install -g create-react-app

  5. Create your react app

    create-react-app appname

lengxuehx
  • 1,500
  • 1
  • 18
  • 25
2

Run the following command which solved my issue

npm install --no-package-lock
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Vishesh
  • 3,599
  • 4
  • 22
  • 36
2

Deleting package-lock.json and installing the desired package again solved the issue for me.

jfk
  • 4,335
  • 34
  • 27
2

Have not seen this answer yet so hope this helps someone.

If you are trying to set up a work environment and using a repository manager such as Artifactory and you are getting this error be sure you are connected to your works VPN. Even if you are disconnect and reconnect.

We had this issue and simply (re)connecting to the VPN fixed the issue.

athammer
  • 159
  • 1
  • 14
1

I stumbled upon this issue when installing local packages from my computer.

I had moved the local packages to another folder. And then when I wanted to update, I started getting this error.

To resolve this, I deleted all the previously created symlinks from the following folder:

C:\Users\<USERNAME>\AppData\Roaming\npm\node_modules

After this i could install packages like before!

Xpleria
  • 5,472
  • 5
  • 52
  • 66
1

I had faced the same issue, and i spend days to get a solution for the issue. In the end, i figured it out and it was an issue with my network.

I was using corporate proxy using a script. When i opened the pac file and get the proxy from there and added, it started working and never ever i faced the same issue.

Amalraj K R
  • 71
  • 1
  • 3
1

Turns out I was out of space! Deleting files on the drive allowed for normal startup and running.

user3413723
  • 11,147
  • 6
  • 55
  • 64
1

My issue was that my proxy settings were not correct for corporate network. Specifically my password was not set in the URL.

lcharbon
  • 3,030
  • 2
  • 16
  • 18
1

I found a couple of other issues that caused this for me, both proxy related.

  1. I use a local proxy to forward to our corporate proxy. My local proxy was running on port 3128. I happened to see while watching the process / listening port list that a different process would start, try to bind to port 3128, then stop. When this happened my local proxy lost its state and quit accepting connections, even though it still had the port bound. In this case I reconfigured my local proxy to listen on port 3129 instead, which removed the port conflict with the other process.
  2. Somewhat similar to above - my local proxy process, just for whatever other reason, would die and leave the port open. I had to kill the process / free the port / reboot and restart my local proxy to get things back.
squillman
  • 13,363
  • 3
  • 41
  • 60
0
brew uninstall node
cd /usr/local
git checkout f7bbdcc /usr/local/Library/Formula/node.rb
brew install node

Find other versions like so:

brew versions node
Alex V
  • 18,176
  • 5
  • 36
  • 35
0

It seems like this issue is not occurring with a specific configuration or node version. We experienced it a couple of times when redeploying and suspect the npm servers to cause this issue.

Retrying a couple of times did solve the issue eventually.

MaxM
  • 625
  • 7
  • 13
0

Check if you have multiple versions of the npm command in your system path variable.

In my case, I had a version in the Node install directory and an older one in the npm globals install directory (called prefix in the npm config file). So I checked npm config get prefix for the location and deleted the link and the npm folder from node_modules. (Deleting the other one might also work, depending on the order in your PATH variable.)

Stefan
  • 12,108
  • 5
  • 47
  • 66
0

For mac users (HighSierra), do not install node using brew. It'll mess up with npm. I had to uninstall node and install using the package in the main nodejs.org source : https://nodejs.org/en/

Here's a simple guide that doesn't use brew: https://coolestguidesontheplanet.com/installing-node-js-on-macos/

0

In my case, I was running npm install from within a Docker container that was running the node:10.16.0-alpine image. The problem was triggered by package.json pointing at a package directly in GitHub:

"dependencies": {
    "gulp-sass-inline-svg": "git+https://github.com/chriswburke/gulp-sass-inline-svg.git"
}

After switching to a Docker image that had git installed, the error went away.

Sam
  • 40,644
  • 36
  • 176
  • 219
0

For me helped turn off antivirus

tomassilny
  • 1,121
  • 1
  • 10
  • 14
  • For sure you are not serious, right? This cannot be the kind of advice to spread out here on SO. While it might help running npm successfully, it is counterproductive as viruses etc. can be downloaded and ran as a worst case scenario. Or even intruding your machine while not using npm. – Michael Nov 01 '21 at 09:47
  • It helped me to solve my problem cause antivirus was blocking the process, then I turned on the antivirus again. Chill out – tomassilny Nov 02 '21 at 12:28
0

Windows WSL, Ubuntu, npm install returns the error. My solution:

sudo npm install

not sure why i have to use sudo. Other solutions like clean cache didn't work for me.

JanBrus
  • 1,198
  • 9
  • 13
0

I was using WSL2 and ubuntu. I had added a .npmrc to home/user and run sudo and then I had this issue. I realized that I had to create my project inside ~ folder ($home/user). It was not working because my project was inside /mnt/c

Nick Mehrdad Babaki
  • 11,560
  • 15
  • 45
  • 70
0

I tried

  1. npm cache verify
  2. npm cache clean --force.
  3. npm i -g npm

but no luck.

But uninstalling previous node version and installing latest node version worked for me.

0

For me was a problem package-lock.json after deleting it and running command to clean cache I was abble to run npm -i successful.

0

I installed a software which generated a .npmrc file under Users/<name>/.npmrc

Removing that .npmrc file solved the issue for me.

Hypermystic
  • 880
  • 2
  • 11
  • 22
0

unset http_proxy; unset https_proxy; unset ftp_proxy fixed it for me, there was a proxy configured for a different network which my docker container was trying to use. Why npm isn't able to just tell me that it can't access the internet is insane.

Shardj
  • 1,800
  • 2
  • 17
  • 43
0

We had the same error on Azure Pipelines but not on our local machine. Unfortunately the error doesnt tell me much about the cause however, here is our solution:

  • Add the 'npmAuthenticate'-task before the npm ci command.

see task description here

hogan
  • 1,434
  • 1
  • 15
  • 32
0

To fix this error permanently, I recommend following these steps:

Windows:

  • 1- Uninstall all packages and programs related to node and its derivatives;

  • 2- Access the following link, and install the node by nvm, through the nvm-setup.exe file. Here is the link to the installation file: https://github.com/coreybutler/nvm-windows/releases Note: There is no need to install node after this installation.

  • 3- After installation, let's install the node through nvm, follow the steps:

    • 3-1: run the following command (in vX.X.X, you decide which version or versions you need): nvm install vX.X.X;
    • 3-2: to use the desired version, execute the following command: nvm use vX.X.X;
    • 3-3: [optional] if you want to set a specific version as default, execute the following command: nvm alias default vX.X.X;
    • 3-4: to check if you are using the version you want, execute the following command: nvm current;
  • 4- After installing and defining the desired version of node, run the command again: npm install;

To fix this error permanently, I recommend following these steps:

Linux:

  • 1- Uninstall all packages and programs related to node and its derivatives;

  • 2- To install NVM just use curl or Wget. Run in the terminal:

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash

or

$ wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
  • 3- After installation, let's install the node through nvm, follow the steps:

    • 3-1: run the following command (in vX.X.X, you decide which version or versions you need): nvm install vX.X.X;
    • 3-2: to use the desired version, execute the following command: nvm use vX.X.X;
    • 3-3: [optional] if you want to set a specific version as default, execute the following command: nvm alias default vX.X.X;
    • 3-4: to check if you are using the version you want, execute the following command: nvm current;
  • 4- After installing and defining the desired version of node, run the command again: npm install;

Following the above steps fixed this problem for me permanently.