我无法安装npm软件包,代理存在问题

时间:2020-01-09 21:58:52

标签: node.js npm proxy centos centos8

我尝试在Centos8上使用npm安装一些软件包,但是我遇到了这个问题:

npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/ejs failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-01-09T16_50_40_483Z-debug.log

我更改了yum.conf,但是喜欢:


gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
#proxy=http://10.30.17.74:443

但是我遇到了同样的问题,请帮助我。

1 个答案:

答案 0 :(得分:0)

尝试通过命令行调用npm install时传递代理设置,如下所示:

http_proxy=http://<yourproxy>:<proxyport> https_proxy=<yourproxy>:<proxy port> npm install <package>