如何清除NPM之前的ssl代理设置? 嗯,我搜索了很多,但我得到的所有帖子主要是关于如何在公司网络中设置代理。

我试图设置代理为空:

npm config set http-proxy
npm config set https-proxy

第一个命令传递,第二个命令警告说:

npm WARN invalid config proxy=""
npm WARN invalid config Must be a full url with 'http://'

警告是否可忽略,我是否已成功清除代理设置?


当前回答

您将从服务器管理员或支持人员处获得代理主机和端口。

在那之后

NPM配置设置http_proxy http://username:password@proxyofmycomp.com:itsport NPM配置设置代理http://username:password@proxyofmycomp.com:itsport 如果密码中有特殊字符,请尝试使用% urlencode。- pound(hash)应该被%23取代。

这对我很管用……

其他回答

我认为不是http-proxy,而是proxy:

npm config set proxy="http://yourproxyhere"

在默认值下,npm从https://registry.npmjs.org寻找包。您还需要重写注册表和严格ssl值。

npm config set registry "http://registry.npmjs.org"
npm config set strict-ssl false

This was already answered but I think the --global config is not covered properly. By running npm config rm proxy you remove proxy from user configuration. This can be easily verified by running: npm config list. If there is proxy or https-proxy setting set in global config you have to use --global in the command to remove it. So at the end this will clean-up proxies from both local and global configs: npm config rm proxy npm config rm https-proxy npm config --global rm proxy npm config --global rm https-proxy

我为此纠结了很久。我最后做的是进入.npmrc文件(可以在用户的目录中找到,后面跟着用户名,例如。C:\Users\erikj/.npmrc),用文本编辑器打开它,手动删除任何代理设置,并将http://设置更改为https://.在这种情况下,这是一个试验是否http或https对你有效的问题。对我来说,https是有效的。图。

好吧,我要把这个放在这里因为我在NPM上遇到了很大的麻烦。

我试图改变一个代理设置使用npm配置设置代理“http://..。然后运行NPM config get proxy。它总是返回一个错误的值,不同于我设置的值。

我发现我在项目上有一个.npmrc committed,我试图运行npm install,这个文件覆盖了我自己的配置。

所以它正在清除代理值,但我还需要更改文件夹项目中的.npmrc。

从那以后,一切都很顺利。