尝试全局安装 Vue CLI 时出现 NPM 代理问题
Posted
技术标签:
【中文标题】尝试全局安装 Vue CLI 时出现 NPM 代理问题【英文标题】:NPM proxy problem when trying to install Vue CLI globally 【发布时间】:2020-11-30 05:46:17 【问题描述】:我尝试全局安装 Vue Cli,但没有安装,并且还显示了一些代理设置错误。我已经手动/cmd 在 .npmrc 文件上添加了一些值,如下所示,但它对我不起作用。
npm config set proxy http://proxy.mycompany.com:8080
npm config set https-proxy http://proxy.mycompany.com:8080
错误如下:
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://registry.npmjs.org/@vue%2fcli failed, reason: connect ETIMEDOUT 104.16.20.35:80
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! C:\Users\Viking_Castle\AppData\Roaming\npm-cache\_logs\2020-08-10T15_30_01_181Z-debug.log
【问题讨论】:
【参考方案1】:我有类似的错误
? Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to https://cdn.npm.taobao.org/%40babel/plugin-transform-unicode-escapes/-/%40babel/plugin-transform-unicode-escapes-7.12.1.tgz failed, reason: connect ETIMEDOUT 129.227.206.207: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! C:\Users\Pradeep S\AppData\Roaming\npm-cache\_logs\2020-11-27T19_57_22_034Z-debug.log ERROR command failed: npm install --loglevel error
R通过将 Wifi 连接更改为笔记本电脑解决了。使用移动热点连接,再次尝试从vue cli创建项目,这次成功了
【讨论】:
【参考方案2】:尝试使用以下命令删除代理并尝试安装它
npm config rm proxy
npm config rm https-proxy
【讨论】:
评论不用于扩展讨论;这个对话是moved to chat。以上是关于尝试全局安装 Vue CLI 时出现 NPM 代理问题的主要内容,如果未能解决你的问题,请参考以下文章
为 vue-cli 运行“npm run dev”时出现跨环境问题
使用 vue/cli 运行 npm run serve 时出现问题
vue启动项目时出现的错误Error: Cannot find module 'D:\node_modules\npm\bin\npm-cli.js'