npm从私有gitlab安装git+ssh

npm从私有gitlab安装git+ssh,git,npm,Git,Npm,我有一个私人的Gitlab。我有一个回购协议,我从这个地址进行git克隆:[git@10.15.8.210:8888]:recsystem/robotRecSystem.git 在节点7.2.1 npm v3.10.10之前,我可以这样安装: $ npm install git+ssh://[git@10.15.8.210:8888]:recsystem/robotRecSystem.git --save src@0.0.0 /home/pauloh/src/recsystem-web/src

我有一个私人的Gitlab。我有一个回购协议,我从这个地址进行git克隆:[git@10.15.8.210:8888]:recsystem/robotRecSystem.git

在节点7.2.1 npm v3.10.10之前,我可以这样安装:

$ npm install git+ssh://[git@10.15.8.210:8888]:recsystem/robotRecSystem.git --save
src@0.0.0 /home/pauloh/src/recsystem-web/src
└── robotRecSystem@1.1.0  (git+ssh://[git@10.15.8.210:8888]:recsystem/robotRecSystem.git#b589aa1d17cb44d5c17e5fd69929a7a8b64c9eba)
但自从node 8.9.0 npm v5.5.1使用同一命令出现错误后:

$ npm install git+ssh://[git@10.15.8.210:8888]:recsystem/robotRecSystem.git --save
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://%5Bgit@10.15.8.210/:8888]:recsystem/robotRecSystem.git
npm ERR! 
npm ERR! ssh: Could not resolve hostname 10.15.8.210/: Name or service not known
npm ERR! fatal: Could not read from remote repository.
npm ERR! 
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR! 
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pauloh/.npm/_logs/2018-07-11T13_00_48_101Z-debug.log
读取错误时,npm在调用git ls remote命令时失败。 它尝试执行以下命令:

/usr/bin/git ls-remote -h -t ssh://%5Bgit@10.15.8.210/:8888]:recsystem/robotRecSystem.git
如果我将此命令更改为:

/usr/bin/git ls-remote -h -t [git@10.15.8.210:8888]:recsystem/robotRecSystem.git
因此,我认为问题在于:

我的url字符串[git@10.15.8.210:8888]:recsystem/robotRecSystem.git不是正常的url,因为它不是protocol://user@主机名:端口/路径 npm未正确解析我的url字符串。 npm正在将字符[更改为%5B,它不起作用 npm正在为协议ssh://添加前缀,但该协议不起作用 如何将url字符串更改为npm并正确解析它?

npm安装文档中的括号

甚至更好


您可以在.ssh/config中定义端口,如中所述:

为什么URL有方括号?我不知道。Gitlab就是这样给我ssh连接的URL,git会识别它。我使用此地址进行git克隆。npm地址似乎已更改,请尝试git+ssh://git@10.15.8.210:8888:recsystem/robotRecSystem.git,看看你自己实际上,最后一点是正确的,对于git+ssh,您告诉npm应该调用git进行克隆,并且应该在git中使用ssh协议。也许可以从URL中删除方括号?我如何将这个git_ssh_命令与npm install或package.json一起使用?好的,第一个选项:8888 after应该可以正常工作,您需要什么重新体验rollbackFailedOptional似乎是一个无关的问题
<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]
GIT_SSH_COMMAND='ssh -p 8888' git+ssh://git@10.15.8.210:recsystem/robotRecSystem.git