【问题标题】:Using git archive as npm dependency使用 git archive 作为 npm 依赖
【发布时间】:2012-02-23 15:31:27
【问题描述】:

使用 npm,您可以使用指向包含节点模块的 gzip 压缩包的 URL 来声明依赖项。我通过在 OSX 终端中运行 tar 命令来完成这项工作。但我宁愿使用 git archive 以便输出不包括 .git 的东西和被 repo (node_modules) 忽略的东西。

我这样创建存档:

git 归档大师 | gzip > ../archive.tar.gz

但是当我尝试使用 npm 安装它时(npm install archive.tar.gz 或将其放入 package.json 中)它失败并出现以下错误:

npm ERR! couldn't unpack /var/folders/gc/6rgb6g4x0n96nc1scbvv87040000gn/T/npm-1329949280846/1329949280846-0.19062370574101806/tmp.tgz to /var/folders/gc/6rgb6g4x0n96nc1scbvv87040000gn/T/npm-1329949280846/1329949280846-0.19062370574101806
npm ERR! Could not install: /javascript/archive.tar.gz
npm ERR! Error: ENOTDIR, not a directory '/var/folders/gc/6rgb6g4x0n96nc1scbvv87040000gn/T/npm-1329949280846/1329949280846-0.19062370574101806/package/package.json'
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "/javascript/archive.tar.gz"
npm ERR! cwd /Users/dave
npm ERR! node -v v0.6.11
npm ERR! npm -v 1.1.0-beta-10
npm ERR! path /var/folders/gc/6rgb6g4x0n96nc1scbvv87040000gn/T/npm-1329949280846/1329949280846-0.19062370574101806/package/package.json
npm ERR! code ENOTDIR
npm ERR! message ENOTDIR, not a directory '/var/folders/gc/6rgb6g4x0n96nc1scbvv87040000gn/T/npm-1329949280846/1329949280846-0.19062370574101806/package/package.json'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/dave/npm-debug.log

知道 git 存档和常规 tar 有什么不同会导致 npm install 失败吗?

【问题讨论】:

  • 您将--format=tar 选项省略为git archive;有可能它创建了一个 zip 吗?
  • tar 是默认值,但是我尝试了显式 --format=tar,效果相同。不过建议尝试一下。

标签: git node.js npm


【解决方案1】:

虽然存档的格式可能在这个问题中起作用(正如评论中提到的Borealid),但我也会仔细检查这是否与参数npm 中的长度问题无关@ 必须处理。
看到这个issue on npm 5 个月前,还有这个fix proposed(这适用于 Windows,但如果路径真的很长,它仍然可能对您的环境产生影响)。

另请参阅issue 1951: "Can't unpack with tar (on Mac)",其中tar 的版本与npm 不兼容(如issue 1511 以及Mac 上)。

【讨论】:

  • 可能是这样的。我会在 npm 网站上发布它,看看它是否确实是一个 npm 错误。感谢您的帮助。
猜你喜欢
  • 2013-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-25
  • 2020-02-24
  • 2020-09-28
  • 2017-10-01
  • 1970-01-01
相关资源
最近更新 更多