【问题标题】:NPM install : Git URL dependency error in package.jsonNPM安装:package.json中的Git URL依赖错误
【发布时间】:2023-03-30 00:31:02
【问题描述】:

我想在我写的 package.json 中设置一个私有包的 Git URL 依赖项:

"dependencies" : { 
    "mymodule" : "git://git@git.myrepo.com:/myproject#mybranch"
}

运行npm install 时出现此错误:

git clone git://git@git.myrepo.com:/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)

但它看起来像 npm 调用 git clone --mirror git://git.myrepo.com ...etc 难道不应该打电话给git clone --mirror git.myrepo.com ...etc吗?

有人已经面对了吗?或者有什么线索?

【问题讨论】:

  • package.json 中的 Git URL 是反模式!
  • 在没有任何解释的情况下将事物称为“反模式”是一种反模式

标签: git node.js npm


【解决方案1】:

有效的表格如下。如果您使用的是用户名@,则需要指定 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

【讨论】:

猜你喜欢
  • 2016-08-02
  • 1970-01-01
  • 1970-01-01
  • 2018-12-25
  • 2020-04-02
  • 2013-09-15
  • 2013-01-17
  • 2015-07-25
  • 1970-01-01
相关资源
最近更新 更多