安装淘宝镜像后命令行报错

  • Post author:
  • Post category:其他
  1. 输入命令行

C:\Users\ZZ05ST672>npm i -g @vue/cli

C:\Users\ZZ05ST672>npm install npm@6.14.10 -g 后

报错如下

npm ERR! code ENOTFOUND

npm ERR! syscall getaddrinfo

npm ERR! errno ENOTFOUND

npm ERR! network request to http://registry.cnpmjs.org/npm failed, reason: getaddrinfo ENOTFOUND registry.cnpmjs.org

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\ZZ05ST672\AppData\Local\npm-cache\_logs\2023-02-14T01_46_25_439Z-debug-0.log

  1. 还原淘宝镜像代理

C:\Users\ZZ05ST672>npm config set registry https://registry.npmjs.org

  1. 之前尝试多次方法后 可以输入命令npm cache clean清除缓存

出现如下报错,

npm ERR! As of npm@5, the npm cache self-heals from corruption issues and data extracted from the cache is guaranteed to be valid. If you want to make sure everything is consistent, use ‘npm cache verify’ instead. On the other hand, if you’re debugging an issue with the installer, you can use `npm install –cache /tmp/empty-cache` to use a temporary cache instead of nuking the actual one.

npm ERR!

npm ERR! If you’re sure you want to delete the entire cache, rerun this command with –force.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\ZZ05ST672\AppData\Roaming\npm-cache\_logs\2023-02-14T01_52_11_748Z-debug.log

可使用强制清除命令npm cache clean –force

若是显示

npm WARN using –force Recommended protections disabled.

那就说明需要降低npm的版本了,因为安装的npm版本过高

降低npm的命令使用如下

C:\Users\ZZ05ST672>npm install npm@6.14.10 -g

输入命令行 npm -v查看版本号

  1. 卸载vue-cli 执行命令:npm uninstall vue-cli -g

检查vue-cli卸载成功没 执行命令:vue -V 出现‘vue’不是内部或外部命令,也不是可运行的程序,代表vue-cli卸载成功了

  1. 安装vue-cli 执行命令:npm install -g @vue/cli

  1. 输入命令vue -h可查看有哪些命令,

如果输入vue -h,没有ui选项,则是vue cli版本问题,可执行4和5两点


版权声明:本文为weixin_60358523原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。