Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

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, 2013 at 18:59 Strangely, adding "engines": { "node": "0.8.x" } to my package.json fixed that error for me. – smithclay Mar 13, 2013 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, 2013 at 14:04 There is currently an open issue about this error with npm and node 0.10.0: github.com/isaacs/npm/issues/2907 – jonathancardoso Mar 15, 2013 at 12:49 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 2, 2015 at 15:14 Workaround helped, but for the same error but during module installation (grunt-contrib-yuidoc), thanks. – Wiseman Jul 22, 2013 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, 2013 at 22:57 Got this error after building a postgres native extension, rm -fr $HOME/.node-gyp do the trick. – Giovanni Toraldo Jul 24, 2014 at 9: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 9, 2014 at 23:34

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"
                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, 2013 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, 2013 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, 2013 at 1:03
                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 1, 2013 at 5:24
                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, 2020 at 21:07

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

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

  • Clear your npm cache: sudo npm cache clean -f
  • Install the latest version of the Node helper: sudo npm install -g n
  • 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.

    According to your source link, this solution is "unstable" and Node Version Manager is better github.com/nvm-sh/nvm/blob/master/README.md – PJ Brunet Mar 29, 2020 at 7:55 Fantastic. That was bugging me for sure. Specified my npm version and it worked like a charm. – Eric H. Jul 4, 2013 at 1:46 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, 2013 at 14:01 Yes. Actually it worked this way for me. First I updated my Node & run those commands it worked. May be another way of getting it worked. Hope it helps some one. – Srinivas Jan 1, 2017 at 12:12

    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/
    

    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.
  • Working!! npm should suggest such solutions along with the error like git does. npm just throws fatal error... – aagjalpankaj Nov 18, 2021 at 9:51 I faced this issue with npm version: 6.14.14 node version: v14.17.5 and above solution worked! Thanks :-) – Siddharth Murugan Jan 4, 2022 at 5:00

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

  • npm cache clean
  • Manually delete cache from %temp%\npm-*
  • 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!

    Installing node may have installed a new npm, which could be the cause of this working as a fix. – mikemaccana Jul 9, 2019 at 10:56

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

    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, 2013 at 6:58 Apparently this bug is now fixed in v0.10.20: blog.nodejs.org/2013/09/30/node-v0-10-20-stable – Sven Viking Oct 1, 2013 at 7:05

    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
    

    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
    

    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.

    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.

  • Check if you have any proxy config

    npm config list
    
  • Delete them by

    npm config delete proxy
    npm config delete http-proxy
    npm config delete https-proxy
    
  • Now try

    npm install
                    it seems like a returning problem, I had the same problem with 10.15.0 and 11.6.0, and I had to downgrade 9.11.2, it worked.
    – CsBalazsHungary
                    Jan 14, 2019 at 14:11
    

    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.

    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 4, 2019 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, 2020 at 15:51

    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.

    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
  • Try switching your network, somehow switching network worked for me.

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

  • npm cache clean --force
  • Delete existing node_modules, delete package-lock.json, and reinstall using - npm i
  • npm cache verify
  • npm clean-install
  • None of the above worked for me, might work for you. Try your luck.

    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.

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

  • I downloaded kaspersky and installed it. then i disabled kaspersky secure connections
  • i opened cmd and run this command npm cache clean --force
  • i then run this command npm install npm@latest -g
  • i then run the firebase cli command npm install -g firebase-tools
  • @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, 2019 at 14:22

    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,

  • Running sudo npm cache clean -f - which did not work as expected
  • 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.

  •