npm 配置源

1,593 阅读1分钟

一、使用cnpm工具

   通过输入“npm install -g cnpm --registry=http://registry.npmmirror.com“来安装cnpm。安装成功后,使用cnpm代替npm来安装依赖包。

二、使用命令行配置 通过命令“npm config set registry registry.npmmirror.com“设置淘宝镜像源,使用npm安装包时,会自动使用淘宝的镜像源。具体步骤:

    1、设置镜像地址:

    打开命令行工具,输入"npm config set registry  https://registry.npmmirror.com"(原域名“https://registry.npm.taobao.org/“已于2022年6月30日停止服务);
    2、验证配置:

    运行“npm config get registry“查看当前配置的镜像地址;
    3、恢复默认配置:

    如需恢复为官方源,执行“npm config set registry https://registry.npmjs.org“。