开发者

NPM on Cygwin: unexpected end of file

开发者 https://www.devze.com 2023-03-07 01:55 出处:网络
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/___packa

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/___pa开发者_运维知识库ckage.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 express@2.3.5 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?


  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>
    


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:

$ rm /tmp/npm-*

then install again. worked for me.


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,


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消