node.js 如何清除 NPM 的 https 代理设置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21228995/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:43:04  来源:igfitidea点击:

How to clear https proxy setting of NPM?

node.jsproxy

提问by Allan Ruin

How can I clear the previous ssl proxy setting of NPM? well, I search a lot, but all post I got is mainly about how to setproxy in corporate network.

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

I try to set proxy to nothing:

我尝试将代理设置为空:

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

the first command pass yet the second one warn that:

第一个命令通过但第二个命令警告:

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

is the warning neglectable and I have successfully clear the proxy setting?

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

回答by sra

None of the above helped me, but this did:

以上都没有帮助我,但这确实帮助了我:

npm config rm proxy
npm config rm https-proxy

Source: http://jonathanblog2000.blogspot.ch/2013/11/set-and-reset-proxy-for-git-and-npm.html

来源:http: //jonathanblog2000.blogspot.ch/2013/11/set-and-reset-proxy-for-git-and-npm.html

回答by Aaron

Try deleting them with:

尝试删除它们:

npm config delete proxy
npm config delete https-proxy

回答by privoxyd

npm config rm proxy
npm config rm https-proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy

Damn finally this does the trick in Debian Jessie with privoxy (ad remover) installed, Thank you :-)

该死的,这在安装了 privoxy(广告去除程序)的 Debian Jessie 中成功了,谢谢:-)

回答by Anatolii Gabuza

This was already answered but I think the --globalconfig is not covered properly.

这已经得到回答,但我认为--global配置没有正确覆盖。

By running npm config rm proxyyou remove proxy from user configuration.
This can be easily verified by running: npm config list.

If there is proxyor https-proxysetting set in global config you have to use --globalin the command to remove it.

通过运行npm config rm proxy您从用户配置中删除代理。
这可以通过运行很容易地验证:npm config list

如果全局配置中有proxyhttps-proxy设置设置,则必须--global在命令中使用以将其删除。

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

回答by M. Oguz Ozcan

In the latest version npm rm proxydoes not work. Instead use npm rm http-proxy

在最新版本npm rm proxy中不起作用。而是使用npm rm http-proxy

npm config rm proxy npm config rm https-proxy

npm config rm proxy npm config rm https-proxy

回答by Shagun Pruthi

I have used the below commands for removing any proxy set:

我已使用以下命令删除任何代理集:

    npm config rm proxy
    npm config rm https-proxy

And it solved my problem :)

它解决了我的问题:)

回答by nagu

If you go through the npm config documentation, it says:

如果您查看npm 配置文档,它会说:

proxy

Default: HTTP_PROXY or http_proxy environment variable, or null

Type: url

代理

默认值:HTTP_PROXY 或 http_proxy 环境变量,或 null

类型:网址

As per this, to disable usage of proxy, proxysetting must be set to null. To set proxy value to null, one has to make sure that HTTP_PROXYor http_proxyenvironment variable is not set. So unset these environment variables and make sure that npm config ls -lshows proxy = null.

据此,要禁用代理的使用,proxy设置必须设置为null。要将代理值设置为 null,必须确保未设置HTTP_PROXYhttp_proxy环境变量。因此,请取消设置这些环境变量并确保npm config ls -l显示proxy = null.

Also, it is important to note that:

此外,重要的是要注意:

  • Deleting http_proxy and https_proxy config settings alone will not help if you still have HTTP_PROXY or http_proxy environment variable is set to something and
  • Setting registry to use http:// and setting strict-ssl to false will not help you if you are not behind a proxy anyway and have HTTP_PROXY set to something.
  • 如果您仍然将 HTTP_PROXY 或 http_proxy 环境变量设置为某些内容,则单独删除 http_proxy 和 https_proxy 配置设置将无济于事
  • 将注册表设置为使用 http:// 并将 strict-ssl 设置为 false 对您没有帮助,如果您无论如何都不在代理后面并且将 HTTP_PROXY 设置为某些东西。

It would have been better if npm had made the type of proxy setting to boolean to switch on/off the proxy usage. Or, they can introduce a new setting of sort use_proxyof type boolean.

如果 npm 将代理设置的类型设置为布尔值来打开/关闭代理使用,那就更好了。或者,他们可以引入一种use_proxy布尔类型的新设置。

回答by Michel Hua

By the default value npmis looking for packages from https://registry.npmjs.org. What you also need to do is override the registryand strict-sslvalues.

默认值npm是从https://registry.npmjs.org. 您还需要做的是覆盖registrystrict-ssl值。

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

回答by hannad rehman

there is a simple way of deleting or removing the npm proxies.

有一种删除或移除 npm 代理的简单方法。

npm config delete proxy
npm config delete https-proxy

回答by Arvind Tony

I had the same problem once.
Follow these steps to delete proxy values:

1.To delete proxy in npm:
(-g is Important)
npm config delete proxy -g
npm config delete http-proxy -g
npm config delete https-proxy -g

Check the npm config file using:
npm config list

我曾经遇到过同样的问题。
请按照以下步骤删除代理值:

1.在 npm 中删除代理:
(-g 很重要)
npm config delete proxy -g
npm config delete http-proxy -g
npm config delete https-proxy -g

使用以下命令检查 npm 配置文件:
npm config list

2.To delete system proxy: set HTTP_PROXY=nullset HTTPS_PROXY=null

2.删除系统代理: set HTTP_PROXY=nullset HTTPS_PROXY=null

Now close the command line and open it to refresh the variables(proxy).

现在关闭命令行并打开它以刷新变量(代理)。