aircraft
aircraft

Reputation: 26896

npm ERR! code Z_BUF_ERROR when install

In my server(CentOS 7.2) I install the dependencies:

npm install 

But I get bellow error:

npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! unexpected end of file

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log

in the /root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log, the info is bellow:

10234 verbose bundle EBUNDLEOVERRIDE: Replacing [email protected]'s bundled version of readable-stream with [email protected].
10235 verbose unlock done using /root/.npm/_locks/staging-ace74a3b0cf47932.lock for /home/ubuntu/source_code_web/vue_admin_site/node_modules/.staging
10236 warn The package iview is included as both a dev and production dependency.
10237 warn [email protected] had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
10238 verbose type OperationalError
10239 verbose stack Error: unexpected end of file
10239 verbose stack     at Gunzip.zlibOnError (zlib.js:152:15)
10240 verbose cwd /home/ubuntu/source_code_web/vue_admin_site
10241 verbose Linux 3.10.0-327.el7.x86_64
10242 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
10243 verbose node v8.4.0
10244 verbose npm  v5.3.0
10245 error code Z_BUF_ERROR
10246 error errno -5
10247 error unexpected end of file
10248 verbose exit [ -5, true ]

I tried use:

npm cache clean

to clean the npm, but fails:

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use 'npm cache verify' instead.
npm ERR! 
npm ERR! If you're sure you want to delete the entire cache, rerun this command with --force.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-02-11T21_13_51_943Z-debug.log

Upvotes: 36

Views: 45243

Answers (9)

Reetu Raj Dubey
Reetu Raj Dubey

Reputation: 46

After trying everything related to npm still the problem persist then it might be caused due to some unwanted cache which are getting deleted in the ".apm" folder. Follow these steps.

  1. Goto -> C:\Users\Your_Username\.atom\.apm\_cacache
  2. Delete all the files(tmp,content,index etc..)
  3. Again try and install the package by command or atom.

This might work for you. :-)

Upvotes: 0

DINESH MANIKANTHA
DINESH MANIKANTHA

Reputation: 21

  1. The network caused the module to download the failure

  2. Install a Taobao image and then it's fine:
    npm install -g cnpm -- registry-https://registry.npm.taobao.org

  3. cnpm install egg -- save

Upvotes: 0

Carver
Carver

Reputation: 109

npm install --cache /tmp/empty-cache

This is what worked for me

Upvotes: 1

I was trying this on Windows 10 and the only solution that worked for me was updating npm by giving

npm install npm@latest -g

Upvotes: 6

SACHIN DUHAN
SACHIN DUHAN

Reputation: 339

  1. "npm cache clean --force"
  2. "npm cache verify"

following steps helped me!! :-)

if problem still persist : "npm i npm"

Upvotes: 16

Sasha Shpota
Sasha Shpota

Reputation: 10300

None of the listed solutions helped in my case. I solved the problem by manually removing the caches folder:

rm -rf ~/.npm/_cacache

Or if npm installed in the root folder:

sudo rm -rf /root/.npm/_cacache

Upvotes: 2

Hemanth Poluru
Hemanth Poluru

Reputation: 831

Try cleaning the cache with the command npm cache clean --force and retry your npm install.

Upvotes: 70

aircraft
aircraft

Reputation: 26896

In the end, I delete the node_modules:

rm -rf node_modules

and deleted the package-lock.json,
then re-install:

npm install 

It works for me.

Upvotes: 14

Vitaly Migunov
Vitaly Migunov

Reputation: 4457

As suggested in npm GitHub

Node 8.9.0+ (and 9+) fix an issue where streams are terminated early in some scenarios. If you're getting this error upgrade to 8.9.

So you can just try to update your node and npm

Upvotes: 5

Related Questions