npm install from git use https instead ssh

Viewed 8876

I have an application with the following package.json file

"dependencies": {
    "package_name": "git+ssh://git@git.scm.domain.com:Domain/package_name.git",
}

I can't change it and I can't use ssh. I tried

git config --global url.https://.insteadOf git://
git config --global url.https://git.scm.domain.com.insteadOf git://git.scm.domain.com

But npm i still throws an error about permission and I see that the url doesn't contain https protocol.

npm ERR! Error while executing:
npm ERR! path to git.exe ls-remote -h -t git@git.scm.domain.com:Domain/repo.git

Is it possible to setup git or npm to use https instead of ssh while installing deps from package.json?

3 Answers
git config --global url."https://github.com/".insteadOf git@github.com:
git config --global url."https://".insteadOf git://

This works perfectly. Also pay attention to the colon at the end of the first line.

git config --global url."https://".insteadOf ssh://

This one worked for me.

I needed to manually delete the offending package entry/reference in package-lock.json and then run the two commands in Alexey's answer.

Related