0

I have a private Gitlab. There I have a repo which I do git clone from this address: [[email protected]:8888]:recsystem/robotRecSystem.git

Until node 7.2.1 (npm v3.10.10) I could install like this:

$ npm install git+ssh://[[email protected]:8888]:recsystem/robotRecSystem.git --save
[email protected] /home/pauloh/src/recsystem-web/src
└── [email protected]  (git+ssh://[[email protected]:8888]:recsystem/robotRecSystem.git#b589aa1d17cb44d5c17e5fd69929a7a8b64c9eba)

But since node 8.9.0 (npm v5.5.1) when I get an error with the same command:

$ npm install git+ssh://[[email protected]:8888]:recsystem/robotRecSystem.git --save
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://%[email protected]/: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

Reading the error, npm fails when calling the command git ls-remote. It tryies this command:

/usr/bin/git ls-remote -h -t ssh://%[email protected]/:8888]:recsystem/robotRecSystem.git

It would work if I change this command to:

/usr/bin/git ls-remote -h -t [[email protected]:8888]:recsystem/robotRecSystem.git

So, I think the problems are:

  • my url string [[email protected]:8888]:recsystem/robotRecSystem.git is not a normal url, since it is not a protocol://user@hostname:port/path
  • npm is not parsing correctly my url string.
  • npm is changing the character [ to %5B and it is not working
  • npm is prefixing the protocol ssh:// and it is not working

How could I change my url string to npm parse it correctly?

7
  • Why does the URL have square brackets? Commented Jul 11, 2018 at 13:34
  • I don't know. That's how Gitlab gives me the url to ssh connection and git recognizes it. I do git clone with this address. Commented Jul 11, 2018 at 13:37
  • The npm adressing seems to have changed, try git+ssh://[email protected]:8888:recsystem/robotRecSystem.git and see yourself Commented Jul 11, 2018 at 13:39
  • Actually the last point is correct, with git+ssh you are telling npm that git should be called for cloning and that ssh protocol should be used inside git. Commented Jul 11, 2018 at 13:41
  • Perhaps remove the square brackets from the URL? Commented Jul 11, 2018 at 13:43

1 Answer 1

1

The brackets in npm install documentation (https://docs.npmjs.com/cli/install)

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]

mean only that this part may not be used, not that you have to include the brackets...

Therefore, git+ssh://[email protected]:8888:recsystem/robotRecSystem.git seems to be what you are looking for.

OR

You can use the definition of GIT_SSH_COMMAND variable to set the port beforehand to eliminate possible problems with the colons:

GIT_SSH_COMMAND='ssh -p 8888' git+ssh://[email protected]:recsystem/robotRecSystem.git

OR even better

You may define the port in the .ssh/config as described in: https://www.digitalocean.com/community/tutorials/how-to-configure-custom-connection-options-for-your-ssh-client

Sign up to request clarification or add additional context in comments.

2 Comments

How would I use this GIT_SSH_COMMAND with npm install or inside package.json?
Well, the first option (:8888 after <host>) should work just fine, what you are experiencing with the "rollbackFailedOptional" seems to be an unrelated issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.