Vue运行npm install报错:npm ERR! 404 Not Found - GET https://repo.huaweicloud.com/repository/npm/.....

报错情况

新建的Vue项目,运行 npm install 报错,报错信息如下:

PS E:\temp\hello-vue> npm install
npm ERR! code E404
npm ERR! 404 Not Found - GET https://repo.huaweicloud.com/repository/npm/magic-string/-/magic-string-0.30.2.tgz
npm ERR! 404
npm ERR! 404  'magic-string@https://repo.huaweicloud.com/repository/npm/magic-string/-/magic-string-0.30.2.tgz' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\username\AppData\Local\npm-cache\_logs\2023-08-16T13_53_59_157Z-debug-0.log

问题原因

应该是华为的镜像仓库访问不到了。

解决方案

修改配置

换成淘宝的镜像仓库。
需要在配置文件 .npmrc 中,修改 registry属性。

registry=https://registry.npm.taobao.org/

打开配置文件的方法

  1. 直接打开配置文件

配置文件,默认在下面位置:

C:\Users\username\.npmrc

打开文件,修改仓库属性。示意如下:

  1. 另一种打开配置文件方式:

在命令行输入如下命令,然后自动打开配置文件。

npm config edit

结果

再安装和运行项目,就不会报错了。能够运行开发和打包。

参考

博客:npm ERR! 404 Not Found

猜你喜欢

转载自blog.csdn.net/sgx1825192/article/details/132329519