简体   繁体   中英

npm install error: ssh: connect to host github.com port 22: Connection timed out

I am trying to install gulp 4 in my project (Windows 7 machine). for that dependency, my package.json looks like:

"gulp": "gulpjs/gulp#4.0"

When I run npm install gulp I get this error:

npm ERR! ssh: connect to host github.com port 22: Connection timed out
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!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
npm verb exit [ 1, true ]

But when I try to clone a repository from GitHub it works fine,

git clone https://github.com/gulpjs/gulp.git

I am running these commands behind a corporate firewall.So I have my proxies set up in my environment variables.

http_proxy : http://proxy.company.com:port
https_proxy : https://proxy.company.com:port

I also tried setting:

npm config set proxy http://proxy.company.com:8080

npm config set https-proxy http://proxy.company.com:8080

I tried the same in environment variables as well.

I also tried:

npm config set proxy http://login:pass@proxy.company.com:port

npm config set https-proxy http://login:pass@proxy.company.com:port

None of the above seems to work. How can I fix this?

I had the same problem. Try this command and run npm install again. This will change all of your urls to starting using https:// which seems to be working for you.

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

In my case there was a problem with proxy. Somehow my proxy settings in global .gitconfig were broken, so I had to run the following commands:

git config --global http.proxy http://login:pass@proxy.url/ip.address:port
git config --global https.proxy http://login:pass@proxy.url/ip.address:port

Also check your npm config file, if u stuck with the same problem

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