Louise K
Louise K

Reputation: 4811

npm ERR cb() never called

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

       > [email protected] 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

       > [email protected] 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 [email protected]:still-chamber-1286.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]: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 [email protected]:still-chamber-1286.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to '[email protected]: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.

Upvotes: 460

Views: 702990

Answers (30)

I resolved the problem configuring the proxy. editing the file /etc/yum.conf and configuring the npm proxy (npm config set proxy http://blablabla:bla/)

Upvotes: 0

mdp
mdp

Reputation: 1446

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"
}

Upvotes: 144

Ram Jawade
Ram Jawade

Reputation: 51

npm update will slove your issue, I was facing same when migrating angular from 12 to 13 I was using Node 14 and npm 6 Updating to Node 16 npm 8 sloved this issue.

Upvotes: 0

Rafael Paes Leme
Rafael Paes Leme

Reputation: 21

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.

Upvotes: 0

hogan
hogan

Reputation: 1551

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

Upvotes: 0

Shardj
Shardj

Reputation: 1969

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.

Upvotes: 0

squillman
squillman

Reputation: 13641

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.

Upvotes: 1

lcharbon
lcharbon

Reputation: 3298

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

Upvotes: 1

athammer
athammer

Reputation: 169

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.

Upvotes: 2

Rumesh Madushanka
Rumesh Madushanka

Reputation: 379

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

Upvotes: 4

Hypermystic
Hypermystic

Reputation: 1020

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

Removing that .npmrc file solved the issue for me.

Upvotes: 0

Malith Senanayake
Malith Senanayake

Reputation: 466

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...

Upvotes: 8

Just Shadow
Just Shadow

Reputation: 11871

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.

Upvotes: 14

DarkNominis
DarkNominis

Reputation: 19

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.

Upvotes: 0

Kashish Dhawan
Kashish Dhawan

Reputation: 34

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.

Upvotes: 0

SUMIT JAIN
SUMIT JAIN

Reputation: 91

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.

Upvotes: 5

Obiwahn
Obiwahn

Reputation: 3087

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).

Upvotes: 7

Nick Mehrdad Babaki
Nick Mehrdad Babaki

Reputation: 12485

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

Upvotes: 0

Kacpers
Kacpers

Reputation: 193

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

Upvotes: 5

jfk
jfk

Reputation: 5257

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

Upvotes: 2

JanBrus
JanBrus

Reputation: 1483

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.

Upvotes: 0

Niv
Niv

Reputation: 51

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 [email protected]

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

Upvotes: 3

tomassilny
tomassilny

Reputation: 1121

For me helped turn off antivirus

Upvotes: 0

user3413723
user3413723

Reputation: 12213

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

Upvotes: 1

Sam
Sam

Reputation: 42337

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.

Upvotes: 0

joe hoeller
joe hoeller

Reputation: 1277

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

npm cache clean --force

Upvotes: 6

Sandeep Thar
Sandeep Thar

Reputation: 1177

Try

sudo npm cache clean --force

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

Upvotes: 84

KrtkNyk
KrtkNyk

Reputation: 141

[Works] try

npm config delete https-proxy

it would have conflicted with proxy.

Upvotes: 11

Sulokit
Sulokit

Reputation: 137

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.

Upvotes: 4

FBC
FBC

Reputation: 1132

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.

Upvotes: 3

Related Questions