8

I have the following package.json file and I am trying to run npm install, but it fails.

    "test": "git+https://<TOKEN>@github.build.test.com/test.git",

I have ssh key matched to github. However even I write the following, it always run with https.

    "test": "git+ssh://[email protected]/test.git",

In both case, I encounter following error message

npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t https://github.build.test.com/test.git
npm ERR!
npm ERR! remote: Password authentication is not available for Git operations.
npm ERR! remote: You must use a personal access token or SSH key.
npm ERR! remote: See https://github.build.test.com/settings/tokens or https://github.build.test.com/settings/ssh
npm ERR! fatal: unable to access 'https://github.build.test.com/test.git/': The requested URL returned error: 403
npm ERR!
npm ERR! exited with error code: 128

If I run above command separately, it works.

git ls-remote -h -t https://<TOKEN>@github.build.test.com/test.git
git ls-remote -h -t ssh://[email protected]/test.git

How can I fix it?

Thanks

1
  • @Vix What is missing from my answer? Can you edit the question and share more details about your specific case? Commented Apr 17, 2019 at 17:02

2 Answers 2

2

First if you have any url.<base>.insteadOf directive in your git configuration:

cd /path/to/repo
git config -l|grep -i insteadOf

And if not, set one of your own:

git config url."ssh://[email protected]".insteadOf  https://github.build.test.com

See then if it is still using https.

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

Comments

0

If you are going to use "git+ssh://[email protected]/test.git" you should be able to clone this repository without passing credentials. Simple git clone git+ssh://[email protected]/test.git shouldn't ask for pass or username.

You probably need to configure your git public/private keys. Your locally used key for cloning must be added to repository config. For example for github is possible to configure it on https://github.com/settings/keys

Comments

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.