node.js 请运行`npm cache clean`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/51607362/
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
Please run `npm cache clean`
提问by FLASH
I'm trying to install IPFS from herenpm install ipfs --saveand it is giving me the error as
我正在尝试从这里安装 IPFS npm install ipfs --save,它给我的错误是
npm ERR! tar.unpack error reading /media/FLASH/Tech/IPFS/ipfs
npm ERR! addLocal Could not install /media/FLASH/Tech/IPFS/ipfs
npm ERR! Linux 4.15.0-29-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "ipfs" "--save"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! 0-byte tarball
npm ERR! Please run npm cache clean
错误!tar.unpack 错误读取/media/FLASH/Tech/IPFS/ipfs
错误!addLocal 无法安装 /media/FLASH/Tech/IPFS/ipfs
错误!Linux 4.15.0-29-通用
错误!argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "ipfs" "--save"
错误!节点 v6.9.2
错误!npm v3.10.9
错误!0 字节的压缩包
错误!请运行 npm cache clean
I tried doing npm cache cleanbut still it is giving me the same error while doing npm install ipfs --save
我试过做,npm cache clean但在做的时候仍然给我同样的错误npm install ipfs --save
I don't know why I'm getting this error. and how to avoid this error.
我不知道为什么会出现此错误。以及如何避免这个错误。
回答by infin80
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 verifyinstead. On the other hand, if you're debugging an issue with the installer, you can use npm install --cache /tmp/empty-cacheto use a temporary cache instead of nuking the actual one.
从 npm@5 开始,npm 缓存会从损坏问题中自我修复,并且从缓存中提取的数据保证是有效的。如果您想确保一切都一致,请npm cache verify改用。另一方面,如果您正在调试安装程序的问题,您可以使用npm install --cache /tmp/empty-cache临时缓存而不是实际缓存。
If you're sure you want to delete the entire cache, rerun:
如果您确定要删除整个缓存,请重新运行:
$ npm cache clean --force
A complete log of this run can be found in: /Users/USERNAME/.npm/_logs/2019-01-08T21_29_30_811Z-debug.log
可以在以下位置找到此运行的完整日志:/Users/USERNAME/.npm/_logs/2019-01-08T21_29_30_811Z-debug.log
回答by Salketer
This error can be due to many many things.
此错误可能是由许多原因造成的。
The key here seems the hint about error reading. I see you are working on a flash drive or something similar? Try to run the install on a local folder owned by your current user.
这里的关键似乎是关于error reading. 我看到你正在使用闪存驱动器或类似的东西?尝试在当前用户拥有的本地文件夹上运行安装。
You could also try with sudo, that might solve a permission problem if that's the case.
您也可以尝试使用sudo,如果是这种情况,这可能会解决权限问题。
Another reason why it cannot read could be because it has not downloaded correctly, or saved correctly. A little problem in your network could have caused that, and the cache clean would remove the files and force a refetch but that does not solve your problem. That means it would be more on the save part, maybe it didn't save because of permissions, maybe it didn't not save correctly because it was lacking disk space...
它无法读取的另一个原因可能是因为它没有正确下载或正确保存。您的网络中的一个小问题可能会导致这种情况,缓存清理会删除文件并强制重新获取,但这并不能解决您的问题。这意味着它会更多地用于保存部分,也许它因为权限而没有保存,也许它没有正确保存因为它缺少磁盘空间......

