npm ERR cb() never called - node.js

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.

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

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

Try
sudo npm cache clean --force
More info refer: https://reactgo.com/npm-err-cb-never-called/

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

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

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

Run npm install -g npm
Then run npm install

Updating the NodeJS https://nodejs.org/en/ Fixed My Issue.
Run npm install -g npm & npm cache clean

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.

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

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!

[Works] try
npm config delete https-proxy
it would have conflicted with proxy.

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

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

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

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

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

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

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

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.

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

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.

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

Related

npm ERR! Cannot read properties of null (reading 'pickAlgorithm')

iam getting below error with npm while creating react app
npm ERR! Cannot read properties of null (reading 'pickAlgorithm')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Nagamanickam\AppData\Local\npm-cache_logs\2021-11-18T12_01_45_525Z-debug.log
my npm version is 8.1.4 and i solve this problem by running :
npm cache clear --force
I resolved it by deleting node_modules and package-lock.json and run npm install again.
solved with npm i --legacy-peer-deps on react-native version .70
Just run these 2 commands :
npm cache clear --force
npm install
Probably it's a project that works with Yarn and not NPM.
Try Yarn instead of NPM.
yarn install
and then you can do
yarn start
or
npm start
Your dependency tree may be broken (due to incompartible peer dependencies) you can try running npm install with --legacy-peer-deps or --force to bypass this issue for the mean time.
I was getting this error from an old branch that had a previous version of node/npm. using the correct version of node helped in my case.
In my case the file .npmrc was corrupt. After deleting it everything worked.
I was getting the same error, but I was able to resolve it by the below described method:
Go to folder -> Local > npm-cache and delete all contents of the npm-cache.
try again with npm command, it should work now.
I solved this by update npm from 6.x to 8.5x, then run npm cache clear --force, npm install, however, it has to change the nodejs from 14 to 17, my env is macOS m1 pro.
In my case i updated npm via:
npm update -g npm
After it, everything worked fine.
Don't know why, i didn't expect it.
I solved deleting node_modules and running this command:
npm cache clear --force

npm ERR! Tracker "idealTree:inflate:" already exists

Every time I try to install packages using npm install, I'm getting npm ERR! Tracker "idealTree:inflate:" already exists error.
I've tried removing node_modules and clearing cache, but no luck for me.
I had the same issue when trying to update a v1 lockfile to v2 with npmv7, as it seems to be the case in your codebase, and the only way to make it work was to delete the lockfile, clear the cache and do a npm i again with the --prefer-dedupe flag.
With the package-lock rebuilt, npm i with no flag worked again, as did npm ci.
Before that, I tried npm i --legacy-peer-deps as it seemed to mimic npm v6 not installing peer dependencies and it failed too, however I think it's interesting to know this flag exists, check out the npm 7 announcement page for more clues : https://github.blog/2021-02-02-npm-7-is-now-generally-available/#peer-dependencies
TLDR
rm package-lock.json
npm cache clear --force
npm i --prefer-dedupe
npm update && npm i works for me.
Source: https://github.com/npm/arborist/issues/330#issuecomment-947803995
What worked for me was:
Remove package-lock.json and node_modules on the project root.
npm cache clear --force
npm install --legacy-peer-deps
Note: I need to install the dependencies with the flag because of the nature of the project, but it should work just by normally reinstalling the deps with npm install.
This error occurs in node v14, I upgrade to node v16.17.0 fix it
This might help others:
In my case I had a very small web app. Just a 'app.js' and a 'readme.md'. No 'package.json'. When deploying (using Azure Deployment Center) it returned with error 'Tracker "idealTree:inflate:" already exists'.
When I committed a 'package.json' file the deployment succeeded.

npm ERR! Unexpected end of JSON input while parsing near '...tore-4.0.0.tgz","file'

I was facing this problem in windows 7 and now on Ubuntu 19.10. I just finished formatting my PC and setup the development environment. Anyone can help?
node v12.16.2
npm v6.14.4
npm install -g gatsby-cli
npm WARN deprecated core-js#2.6.11: core-js#<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
npm ERR! Unexpected end of JSON input while parsing near '...tore-4.0.0.tgz","file'
npm ERR! A complete log of this run can be found in:
npm ERR! /home/rodrigo/.npm/_logs/2020-04-14T03_11_30_986Z-debug.log
When a retry to run npm install -g gatsby-cli
, this is what happens:
npm ERR! Response timeout while trying to fetch https://registry.npmjs.org/emoji-regex (over 30000ms)
I have to change the registry of npm.
npm config set registry "https://registry.npmjs.com/"
Then clear the cache.
npm cache clean --force
And finally run the gatsby installer.
npm install -g gatsby-cli
Two issues here. The first, relating to the So this happens when you have an interruption in connection and you were in the middle of parsing some of those JSON files during an install. They are supposed to auto repair but sometimes you will need to:
npm cache clean --force
to clear down the cache manually.
The second is due to the fact you have not set a registry to pull the packages from.
npm config set registry "https://registry.npmjs.com/"
Then you will need to reinstall with
npm install -g gatsby-cli

ng new give "npm ERR! code EINTEGRITY required sha1 but found sha512"

I am trying to create a new project in Angular 7, but getting the below error.
npm ERR! code EINTEGRITY
npm ERR! sha1-SKjl7xiAdhfuK14zwRlMNbQ5Ukw= integrity checksum failed when using sha1: wanted sha1-SKjl7xiAdhfuK14zwRlMNbQ5Ukw= but got sha512-3ds0bW0f5xtxepS3MKBqKiG2i93CTT5cG6vlfsoFDIps7lzcSnZweu3t15S90EacDpenHFyAQdpJlCaMpyLROA== sha1-X4ctB1ciOMPTjjyMj8IQXIHbMBU=. (197 bytes)
Tried every possible solution on my system, but none is helping me out.
Below is the list of solutions I have tried.
nmp install latest
clear cache
remove node_modules
force clear cache
uninstall angular and reinstall angular
These errors are sometimes due to caching or your .lock file.
So here are some steps you may follow to fix the issue.
Remove node_modules rm -rf node_modules
remove your package-lock.json file
clear the cache. npm cache clean --force
verify the cache npm cache verify
Then run npm install --registry https://registry.cnpmjs.org
If it doesn't work try to update you package manager running
npm i -g npm
Then, run npm install again.

Node error npm ERR! cb() never called

When I am running the command npm install npm#latest -g
I am getting below error :-
npm WARN tar zlib error: unexpected end of file
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>
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dk\AppData\Roaming\npm-cache\_logs\2018-04-10T03_25_52_880Z-debug.log
i googled it and tried so many things,nothing worked.
To anyone stumbling upon this question, if you are facing the same error message on npm install, then npm install --no-package-lock solved it for me.
As suggested in the referenced Github issue in Mohit Mutha's comment above, this is especially true if the command is ran in a CI/CD pipeline, or in my case, in Docker.
EDIT: Reason being is that the package-lock.json file already exists in your Docker image or CI pipeline
Full details
Our team encountered this error in our CI pipeline. However, the top answer of using --no-package-lock actually causes npm to also not use a present package-lock.json, which is definitely not the desired behavior for CI. Instead, using npm ci is now the recommended way to install in CI since it will use the existing package-lock (and nothing else).
Solved by running
sudo npm cache clean --force
and after that deleting package-lock.json and node_modules
and then performing
npm install
FYI I have gone through DOZENS of these responses for the exact same ask posted here again and again in SO. I think most of responses are valid. But in my case the actual issue was the CORPORATE PROXY not npm itself.
In my Dockerifle I had to explicitly add http-proxy and https-proxy to my npm config prior to running the npm install and it worked. FYI you need to tell npm config about your proxy or it wont download dependencies and this is what was throwing the cb() never called error - this works in both local (terminal) and docker containers.
...
RUN npm config set http-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm config set https-proxy http://mycompanyproxy.mycompany.com:8099
RUN npm install
EXPOSE 3000
CMD ["node", "server"]

Resources