简体   繁体   中英

npm install from git use https instead ssh

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM