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.
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.
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 .
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With