Cygwin 上的 NPM:文件意外结束

发布于 2024-11-08 11:58:13 字数 1365 浏览 2 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

坚持沉默 2024-11-15 11:58:13
  1. 吹走 tmp 目录

    <前><代码>rm -R /tmp/*

  2. 清除 npm 的缓存

    npm 缓存清理
    
  3. 退出当前 shell 并启动 ash 或 dash shell(从 cygwin/bin 中)

  4. 在 ash(或 dash)shell 中执行 rebaseall 命令。

    <前><代码>/bin/rebaseall -v

  5. 退出并重新启动新的 bash shell。

  6. 再次尝试您的 npm 命令。

    npm install ;
    
  1. Blow the tmp directory away

    rm -R /tmp/*
    
  2. Clear npm's cache

    npm cache clean
    
  3. Exit out of your current shell and start a ash or dash shell up (from in cygwin/bin)

  4. In the ash (or dash) shell execute the rebaseall command.

    /bin/rebaseall -v
    
  5. Exit out and restart a new bash shell.

  6. Try your npm command again.

    npm install <package>
    
想挽留 2024-11-15 11:58:13

我自己也经常遇到同样的问题。

我不知道如何修复它,但我确实知道错误会不规则地发生。如果您尝试再次安装 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.

剩余の解释 2024-11-15 11:58:13

尝试使用以下命令删除临时文件:

$ rm /tmp/npm-*

然后再次安装。为我工作。

Try to remove temp files with this command:

$ rm /tmp/npm-*

then install again. worked for me.

吃→可爱长大的 2024-11-15 11:58:13

/usr/local/lib/node_modules/npm/lib/utils/tar.js 的小补丁

--- tar.js.old 2011-07-15 15:23:09.205440100 +0700
+++ tar.js 2011-07-15 15:25:58.327113300 +0700
@@ -20,6 +20,7 @@
, relativize = require("./relativize")
, cache = require("../cache")
, excludes = require("./excludes")
+ , child_process = require("child_process");

exports.pack = pack
exports.unpack = unpack
@@ -168,13 +169,17 @@
//console.error(npm.config.get("gzipbin")+" --decompress --stdout "
// +tarball+" | "+npm.config.get("tar")+" -mvxpf - -o -C "
// +tmp)
- pipe( spawn( npm.config.get("gzipbin")
- , ["--decompress", "--stdout", tarball]
- , process.env, false )
- , spawn( npm.config.get("tar")
- , ["-mvxpf", "-", "-o", "-C", tmp]
- , process.env, false )
- , function (er) {
+ // pipe( spawn( npm.config.get("gzipbin")
+ // , ["--decompress", "--stdout", tarball]
+ // , process.env, false )
+ // , spawn( npm.config.get("tar")
+ // , ["-mvxpf", "-", "-o", "-C", tmp]
+ // , process.env, false )
+ // , function (er) {
+
+ child_process.exec(npm.config.get("gzipbin")+" --decompress --stdout "
+ +tarball+" | "+npm.config.get("tar")+" -mvxpf - --no-same-owner -C " +tmp
+ , function (er, stdout, stderr) {
// if we're not doing ownership management,
// then we're done now.
if (er) return log.er(cb,

small patch for /usr/local/lib/node_modules/npm/lib/utils/tar.js

--- tar.js.old 2011-07-15 15:23:09.205440100 +0700
+++ tar.js 2011-07-15 15:25:58.327113300 +0700
@@ -20,6 +20,7 @@
, relativize = require("./relativize")
, cache = require("../cache")
, excludes = require("./excludes")
+ , child_process = require("child_process");

exports.pack = pack
exports.unpack = unpack
@@ -168,13 +169,17 @@
//console.error(npm.config.get("gzipbin")+" --decompress --stdout "
// +tarball+" | "+npm.config.get("tar")+" -mvxpf - -o -C "
// +tmp)
- pipe( spawn( npm.config.get("gzipbin")
- , ["--decompress", "--stdout", tarball]
- , process.env, false )
- , spawn( npm.config.get("tar")
- , ["-mvxpf", "-", "-o", "-C", tmp]
- , process.env, false )
- , function (er) {
+ // pipe( spawn( npm.config.get("gzipbin")
+ // , ["--decompress", "--stdout", tarball]
+ // , process.env, false )
+ // , spawn( npm.config.get("tar")
+ // , ["-mvxpf", "-", "-o", "-C", tmp]
+ // , process.env, false )
+ // , function (er) {
+
+ child_process.exec(npm.config.get("gzipbin")+" --decompress --stdout "
+ +tarball+" | "+npm.config.get("tar")+" -mvxpf - --no-same-owner -C " +tmp
+ , function (er, stdout, stderr) {
// if we're not doing ownership management,
// then we're done now.
if (er) return log.er(cb,
走野 2024-11-15 11:58:13

如果发生这种情况,请尝试从 .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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文