【发布时间】: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,效果相同。不过建议尝试一下。