一、引言
最近在做vue项目后,需要执行一个 npm install 的命令来安装项目所需要的依赖文件,但是报错了:
I’m all done. Running npm install for you to install the required dependencies. If this fails, try running the command yourself.
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\bsoft\AppData\Roaming\npm-cache\_logs\2020-03-18T04_43_16_311Z-debug.log
二、解决
最后在网上找了很多资料,有替换 npm 国内源的方法(实测不行),后来找到一个清除 npm 缓存的方法,自测可行:
npm cache clean --force
然后执行 npm install 就可以了