Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 962
F11 Avatar asked Apr 10 '18 03:04

F11


People also ask

How do I clear Nodejs cache?

Run: “npm cache clean –force” are both not working and you still can't clear the cache, you can force clear the cache by running: npm cache clean --force or npm cache clean -f . This will force delete the npm cache on your computer.

Does npm install Dev dependencies?

By default, npm install will install all modules listed as dependencies in package. json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .


2 Answers

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

like image 81
Anas Tiour Avatar answered Oct 09 '22 07:10

Anas Tiour


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

like image 11
Justin Dehorty Avatar answered Oct 09 '22 08:10

Justin Dehorty