执行:npm install 时,报错:If you are behind a proxy, please make sure that the ‘proxy’ config is set properly.
错误意思:npm错误! 网络如果是一个代理,请确保 npm错误!网络“代理”配置设置正确. 参见: npm help config
原因:后台设置的proxy代理环境有问题,可能会有缓存。
方法一:可以关闭代理然后清理代理环境再进行下载
#1. 设置代理关闭
npm config set proxy false
或更改为淘宝镜像 (查看当前镜像源:npm config get registry // 默认情况下是官方默认全局镜像源: https://registry.npmjs.org)
npm config set registry https://registry.npmmirror.com/
#2. 清除缓存
npm cache clean
#若清除失败则使用强制清除缓存指令
npm cache clean --force
#3. 执行安装命令
npm i
方法二:检查 npm 代理设置,删除掉 npm 代理设置
#1. 检查 NPM 代理设置
npm config get proxy
npm config get https-prox
#2. 删除掉 NPM 代理设置
npm config rm proxy
npm config rm https-proxy
#3. 再次检查 NPM 代理设置
npm config get proxy
#再次执行安装命令安装依赖
npm i