npm 无法通过 Socks5 代理安装

问题描述 投票:0回答:6

我在通过socks5代理运行

npm install
时遇到问题。

代理在本地运行,通过 ssh 将 http(s) 隧道传输到公司内网:

ssh -vvv -D 5000 -N <SERVER_IP>

我已经配置了npm的代理:

npm config set proxy socks5h://localhost:5000
npm config set https-proxy=socks5h://localhost:5000

我刚刚得到:

npm ERR! git clone https://<INTRANET>/repo fatal: unable to access 'https://<INTRANET>/repo/': Could not resolve host: <INTRANET>

有什么想法吗?

P.S.:来自同一个 git 仓库地址的 git 克隆工作完美。

node.js git proxy npm socks
6个回答
1
投票

好吧,目前npm不支持socks代理:https://github.com/npm/npm/issues/6204

我现在使用ProxyCap。 http://www.proxycap.com 效果很好。它将管理 ssh 隧道+socks 代理并通过它自动路由所有流量(也适用于 npm)。


1
投票

Proxifier 对我有用。只需添加代理即可

npm install ...

.com/mac/


1
投票

您可以使用

polipo
sock5
代理转换为
http
代理,如果您在 Linux 下,这非常方便。

您可以参考此页面了解更多详情:


1
投票

要获得同时适用于

Linux
Windows
的解决方法,您可以使用
http-proxy-to-socks

$ npm install -g http-proxy-to-socks
$ hpts -s 127.0.0.1:1080 -p 8080

现在你在端口 8080 有了 http 代理。


0
投票

使用 v2rayN 作为客户端。

它将启动

socks5
http
代理。

然后您可以同时将其

http
代理用于
npm
代理,同时将
socks5
用于其他代理。

// http for npm
npm config set http-proxy http://127.0.0.1:10809

// socks5 for git
git config --global http.proxy 'socks5://127.0.0.1:10808

v2raN UI 屏幕截图


0
投票

npm config -L user set https-proxy=socks5h://127.0.0.1:9050
为我工作
tor
。用
npm config -L user get https-proxy
检查一下。

© www.soinside.com 2019 - 2024. All rights reserved.