npm使用国内淘宝镜像的方法
一.通过命令配置
-
命令
npm config set registry https://registry.npm.taobao.org -
验证命令
npm config get registry
如果返回https://registry.npm.taobao.org,说明镜像配置成功。
二、通过使用cnpm安装
-
安装cnpm
npm install -g cnpm --registry=https://registry.npm.taobao.org 解决安装卡顿或无法安装: # 注册模块镜像 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 -
使用cnpm
cnpm install xxx

本文介绍了如何通过命令行配置和使用cnpm来设置npm的国内淘宝镜像,以解决npm安装过程中的卡顿和失败问题。首先,通过`npm config set registry https://registry.npm.taobao.org`命令配置镜像,然后验证是否成功。若要使用cnpm,需先执行一系列命令安装并配置,最后用`cnpm install xxx`进行包的安装。

2万+

被折叠的 条评论
为什么被折叠?



