Cygwin 上的 NPM:文件意外结束
我正在尝试在 cygwin 上使用 NPM,但不断收到以下错误:
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Unexpected EOF in archive
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Unexpected EOF in archive
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Error is not recoverable: exiting now
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm"
ERR! Failed unpacking /tmp/npm-1305893882865/1305893885765-0.008730818051844835/tmp.tgz
ERR! couldn't unpack /tmp/npm-1305893882865/1305893885765-0.008730818051844835/tmp.tgz to /tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents
verbose about to build /home/Tema/node_modules/express
ERR! error installing [email protected] Error: Failed tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm"
我在 google 上搜索了一些建议(npm cache clean 和 rebaseall),但没有任何帮助。那么,有没有办法在Cygwin中使用NPM呢?
I am trying to use NPM on cygwin, but keep getting following errors:
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Unexpected EOF in archive
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Unexpected EOF in archive
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm" tar: Error is not recoverable: exiting now
ERR! tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm"
ERR! Failed unpacking /tmp/npm-1305893882865/1305893885765-0.008730818051844835/tmp.tgz
ERR! couldn't unpack /tmp/npm-1305893882865/1305893885765-0.008730818051844835/tmp.tgz to /tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents
verbose about to build /home/Tema/node_modules/express
ERR! error installing [email protected] Error: Failed tar "-mvxpf" "-" "--no-same-owner" "-C" "/tmp/npm-1305893882865/1305893885765-0.008730818051844835/contents/___package.npm"
There are couple advices I googled (npm cache clean and rebaseall), but nothing helped. So, is there any way to use NPM in Cygwin?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
吹走 tmp 目录
<前><代码>rm -R /tmp/*
清除 npm 的缓存
退出当前 shell 并启动 ash 或 dash shell(从 cygwin/bin 中)
在 ash(或 dash)shell 中执行 rebaseall 命令。
<前><代码>/bin/rebaseall -v
退出并重新启动新的 bash shell。
再次尝试您的 npm 命令。
Blow the tmp directory away
Clear npm's cache
Exit out of your current shell and start a ash or dash shell up (from in cygwin/bin)
In the ash (or dash) shell execute the rebaseall command.
Exit out and restart a new bash shell.
Try your npm command again.
我自己也经常遇到同样的问题。
我不知道如何修复它,但我确实知道错误会不规则地发生。如果您尝试再次安装 npm 包,它可能会起作用。只要继续重试,最终就会成功。
当它卡在 100% cpu 时,只需取消它(ctrl+c)并重试。另外,在安装软件包时不要切换到另一个窗口。
您还可以使用 wget 和 tar 在
node_modules
文件夹中手动安装软件包。I have the same issue myself very often.
I don't know how to fix it, however I do know that the error happens irregularly. If you try to install the npm package again, it may work. Just keep retrying and it will work eventually.
When it gets stuck at 100% cpu, just cancel it (ctrl+c) and try again. Also, don't switch to another window while you are installing a package.
You can also just manually install the package with wget and tar inside the
node_modules
folder.尝试使用以下命令删除临时文件:
然后再次安装。为我工作。
Try to remove temp files with this command:
then install again. worked for me.
/usr/local/lib/node_modules/npm/lib/utils/tar.js 的小补丁
small patch for /usr/local/lib/node_modules/npm/lib/utils/tar.js
如果发生这种情况,请尝试从 .npm 目录(可能位于主目录:~/.npm)中删除部分提取的模块,然后重试(两次或多次)。
If it happen, try to delete partially extracted modules from .npm directory (might be located in home directory: ~/.npm) and try again (twice or more).