首页 > 解决方案 > 输入 npm install -g @angular/cli 后出错

问题描述

C:\Users\91732>npm install -g @angular/cli npm 错误!代码 ENOTFOUND npm 错误!errno ENOTFOUND npm 错误!对 http://infynexus/nexus/repository/npm-all/ 的网络请求失败,原因:getaddrinfo ENOTFOUND infynexus npm ERR!网络 这是与网络连接有关的问题。npm 错误!网络 在大多数情况下,您使用代理服务器或网络设置错误。npm 错误!网络 npm 错误!网络 如果您在代理后面,请确保 npm ERR! 网络“代理”配置设置正确。请参阅:'npm 帮助配置'

标签: angular7

解决方案


它看起来像一个代理问题:

首先尝试删除您的 npm 代理配置:

npm config delete proxy

尝试再次运行 npm install。

如果它仍然不起作用,您将不得不手动设置代理配置(也许您在公司)

npm config set proxy "http://username:password@proxy.company.com:port"
npm config set https-proxy "http://username:password@proxy.company.com:port"

如果上述任何更改有效,请尝试更改您的存储库 url:

npm cache clean --force

运行 npm install (即使你有任何错误)并设置新的 repo:

npm install

npm config set registry https://registry.npmjs.org/

然后再试一次

npm install -g @angular/cli

推荐阅读