NPM 安装:package.json 中的 Git URL 依赖错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16423226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NPM install : Git URL dependency error in package.json
提问by Ostro
I want to set a dependency that is a Git URL of a private package in package.json I write :
我想设置一个依赖项,它是我写的 package.json 中私有包的 Git URL:
"dependencies" : {
"mymodule" : "git://[email protected]:/myproject#mybranch"
}
When running npm install
I get this error :
运行时出现npm install
此错误:
git clone git://[email protected]:/myproject.git Cloning into bare repository '/hom
/Ostro/.npm/_git-remotes/git-git-myrepo-com-myproject-git-4d838f3d'...
npm ERR! git clone git://git.myrepo.com:/myproject.git
npm ERR! git clone git://git.myrepo.com:/myproject.git fatal: Unable to look up
git.myrepo.com (port ) (Servname() not supported for ai_socktype)
npm ERR! Error: git "clone" "--mirror" "git://git.myrepo.com:/myproject.git" "/hom
/Ostro/.npm/_git-remotes/git-git-myrepo-com-myproject-git-4d838f3d" failed with 128
npm ERR! at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/exec.js:56:20)
npm ERR! at ChildProcess.EventEmitter.emit (events.js:99:17)
npm ERR! at maybeClose (child_process.js:638:16)
npm ERR! at Socket.ChildProcess.spawn.stdin (child_process.js:815:11)
npm ERR! at Socket.EventEmitter.emit (events.js:96:17)
npm ERR! at Socket._destroy.destroyed (net.js:358:10)
npm ERR! at process.startup.processNextTick.process._tickCallback (node.js:245:9)
But it looks like npm call git clone --mirror git://git.myrepo.com ...etc
does it not suppose to call git clone --mirror git.myrepo.com ...etc
instead ?
但看起来 npm callgit clone --mirror git://git.myrepo.com ...etc
不应该调用git clone --mirror git.myrepo.com ...etc
吗?
Do someone already face that ? or have any clue ?
有人已经面对了吗?或有任何线索?
回答by Jonathan Wiepert
The valid forms are below. If you are using username@, you need to specify either ssh or https. Also, I am not sure the :/ is valid if you are not using an account.
有效表格如下。如果您使用 username@,则需要指定 ssh 或 https。另外,如果您没有使用帐户,我不确定 :/ 是否有效。
git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish