首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >npm错误!安装时代码Z_BUF_ERROR

问npm错误!安装时代码Z_BUF_ERROR
EN

Stack Overflow用户
提问于 2018-02-12 05:23:40
回答 9查看 40.5K关注 0票数 35

在我的服务器(CentOS 7.2)中,我安装了依赖项:

代码语言:javascript
复制
npm install 

但我会说出错误:

代码语言:javascript
复制
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

在/root/.npm/_logs/2018-02-11T21_03_20_261Z-debug.log中,信息如下:

代码语言:javascript
复制
10234 verbose bundle EBUNDLEOVERRIDE: Replacing npm@1.4.29's bundled version of readable-stream with readable-stream@1.0.34.
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 npm@1.4.29 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 ]

我试过使用:

代码语言:javascript
复制
npm cache clean

清理国家预防机制,但失败:

代码语言:javascript
复制
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
EN

回答 9

Stack Overflow用户

回答已采纳

发布于 2018-02-12 13:27:54

最后,我删除了node_modules

代码语言:javascript
复制
rm -rf node_modules

删除了package-lock.json,

然后重新安装:

代码语言:javascript
复制
npm install 

对我来说很管用。

票数 13
EN

Stack Overflow用户

发布于 2018-04-25 16:54:19

尝试使用命令npm cache clean --force清理缓存,然后重试npm安装。

票数 69
EN

Stack Overflow用户

发布于 2019-01-05 20:48:41

  1. "npm缓存清洁-强制“
  2. "npm缓存验证“

以下步骤对我有帮助:

如果问题仍然存在:" npm“

票数 16
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48739985

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档