运行 npm install - 如何配置不使用 SSH(端口被防火墙阻止)

ant*_*gle 6 git npm-install

当我运行时npm install,大多数模块都配置正确。然而,至少有一个人想要点击一个ssh://地址来拉取模块。不幸的是,我的公司有一项政策,不允许内部网络之外的 SSH 连接。

我得到的具体错误是:

Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://git@github.com/pemrouz/buble.git
npm ERR!
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! exited with error code: 128
Run Code Online (Sandbox Code Playgroud)

我的 package.json 中没有定义 buble,所以它显然是一个其他依赖的库。

有没有办法将 NPM 配置为不使用 ssh:// 地址?我假设我应该能够像所有其他地址一样从 HTTP 地址下载模块——我可以告诉它总是从 SSH 转换为 HTTP 吗?

我尝试了一些我在网上找到的东西:

git config --global url."https://".insteadOf ssh://npm config set ssl-strict=false

这些都没有解决这个特定的问题。

Von*_*onC 8

我尝试了一些在网上找到的东西:

git config --global url."https://".insteadOf ssh://
Run Code Online (Sandbox Code Playgroud)

实际的命令是:

git config --global url."https://github.com".insteadOf ssh://git@github.com
Run Code Online (Sandbox Code Playgroud)

否则,Git 会尝试使用类似 的 URL https://git@github.com,这可能不会得到很好的支持。

npm仍然提到 SSH,然后检查运行该npm命令的用户:它需要与您进行全局配置的用户相同。