在工作中,我们使用HTTP代理,而git协议(端口9418)被拒绝。我的项目具有NPM依赖项,其中一些依赖项具有使用git协议的依赖项,例如:
在我的package.json
"dependencies": {
"jsdoc3" : "git+https://github.com/jsdoc3/jsdoc.git"
}和jsdoc3的package.json:
"dependencies": {
"crypto-browserify": "git://github.com/dominictarr/crypto-browserify.git#95c5d505",
"github-flavored-markdown": "git://github.com/hegemonic/github-flavored-markdown.git"
}我如何才能获得这些依赖关系,如何告诉NPM使用git+https://协议而不是git://协议,或者能够使用git协议?
为了简化操作,我使用windows (在Linux上创建SSH隧道会更容易),并且我使用GIT-Bash。
谢谢
发布于 2013-10-31 23:05:34
您可以使用以下命令告诉git使用https而不是git://:
git config --global url."https://".insteadOf git://发布于 2013-02-19 19:03:40
最终我找到了一个糟糕的解决方案,但它工作得很好。我已经修改了NPM的代码,用http协议取代了git协议(感谢开源)
在npm v1.1.69上,在文件npm/lib/cache.js中,我向函数addRemoteGit添加了以下代码行
// ssh paths that are scp-style urls don't need the ssh://
if (parsed.pathname.match(/^\/?:/)) {
u = u.replace(/^ssh:\/\//, "")
}
//begin trick
if(/^git:/.test(u)){
u = u.replace(/^git/, 'https');
}
//end trick
log.verbose("addRemoteGit", [u, co])发布于 2015-06-05 22:29:35
npm wiki中建议使用两个git命令(参考:npm uses git:// and ssh+git:// only by default)。
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://https://stackoverflow.com/questions/14937405
复制相似问题