node.js 错误!安装时代码 Z_BUF_ERROR
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48739985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm ERR! code Z_BUF_ERROR when install
提问by aircraft
In my server(CentOS 7.2) I install the dependencies:
在我的服务器(CentOS 7.2)中,我安装了依赖项:
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:
在/root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log,信息如下:
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,但失败:
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
采纳答案by aircraft
In the end, I delete the node_modules:
最后,我删除了node_modules:
rm -rf node_modules
and deleted the package-lock.json,
then re-install:
并删除package-lock.json,
然后重新安装:
npm install
It works for me.
这个对我有用。
回答by Hemanth Poluru
Try cleaning the cache with the command npm cache clean --forceand retry your npm install.
尝试使用命令清理缓存 npm cache clean --force并重试 npm 安装。
回答by SACHIN DUHAN
- "npm cache clean --force"
- "npm cache verify"
- “npm 缓存清理 --force”
- “npm 缓存验证”
following steps helped me!! :-)
以下步骤帮助了我!!:-)
if problem still persist : "npm i npm"
如果问题仍然存在:“npm i npm”
回答by Vitaly Migunov
As suggested in npm GitHub
正如 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.
Node 8.9.0+(和 9+)修复了在某些情况下流提前终止的问题。如果您收到此错误,请升级到 8.9。
So you can just try to update your node and npm
所以你可以尝试更新你的节点和 npm
回答by Sasha Shpota
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 npminstalled in the root folder:
或者如果npm安装在根文件夹中:
sudo rm -rf /root/.npm/_cacache
回答by Yashodha Samarawickrama
I was trying this on Windows 10 and the only solution that worked for me was updating npm by giving
我在 Windows 10 上尝试这个,唯一对我有用的解决方案是通过给
npm install npm@latest -g
npm 安装 npm@latest -g
回答by Carver
npm install --cache /tmp/empty-cache
npm install --cache /tmp/empty-cache
This is what worked for me
这对我有用

