2013-05-07 163 views
19

的Git URL相關性錯誤我想設置的依賴是一個私人包的一個Git URL中的package.json我寫:NPM安裝:在的package.json

"dependencies" : { 
    "mymodule" : "git://[email protected]:/myproject#mybranch" 
} 

當運行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) 

但它看起來像故宮呼叫git clone --mirror git://git.myrepo.com ...etc 它不要以爲叫git clone --mirror git.myrepo.com ...etc呢?

做某人已經面對那個嗎?或有任何線索?

+0

'package.json'中的Git URL是反模式的! – hellboy 2014-10-28 18:30:19

回答

41

有效的表格如下。如果您使用的是用戶名@,則需要指定ssh或https。另外,如果您沒有使用帳戶,我不確定:/有效。

git://github.com/user/project.git#commit-ish 
git+ssh://[email protected]:project.git#commit-ish 
git+ssh://[email protected]/project.git#commit-ish 
git+http://[email protected]/project/blah.git#commit-ish 
git+https://[email protected]/project/blah.git#commit-ish 
+0

thx它解決了問題 – Ostro 2013-05-13 08:30:53

+0

如果您使用私有REPO,只需按照相同的模式連接它:例如,我分叉了一個NPM模塊並推送到專用的Atlessian Stash服務器在私人git repo中...我的依賴是以下內容:「crafity」:「git + https://repos.xxx.com/scm/project-a/isp-npm-module-loggin.git#HEAD」 – 2014-08-15 00:09:47