报错情况

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

PS E:temphello-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:UsersusernameAppDataLocalnpm-cache_logs2023-08-16T13_53_59_157Z-debug-0.log

问题原因

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

解决方案

修改配置

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

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

打开配置文件方法

  1. 直接打开配置文件

配置文件默认在下面位置

C:Usersusername.npmrc

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

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

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

npm config edit

结果

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

参考

博客:npm ERR! 404 Not Found

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注