npm. 配置淘宝镜像方法

一、通过命令配置

更新:淘宝镜像站已经切换新域名啦

旧的 https://registry.npm.taobao.org/ 已停止使用了

1、淘宝最新镜像

npm config set registry https://registry.npmmirror.com

2、设置官方镜像源

npm config set registry https://registry.npmjs.org

3、查看镜像使用状态:

npm config get registry

若返回 "https://registry.npmmirror.com/",说明配置的淘宝最新的镜像;
如果返回 "https://registry.npmjs.org/",说明配置的是官方镜像。

二、通过使用cnpm安装

1、安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

三、解决安装卡顿或无法安装,设置cnpm

1、安装cnpm

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

node-gyp 编译依赖的 node 源码镜像

npm set disturl https://npm.taobao.org/dist

清空缓存

npm cache clean --force

安装cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org

2、使用cnpm

cnpm install xxx
posted @ 2023-06-17 00:19  大雷小屋  阅读(19336)  评论(0编辑  收藏  举报