【vue】npm 切换淘宝镜像几种方式
npm 淘宝镜像 cnpm
·
有很多方法来配置npm的registry地址,下面根据不同情境列出几种比较常用的方法。以淘宝npm镜像举例:
1.临时使用
npm --registry https://registry.npm.taobao.org install express
2.持久使用
npm config set registry https://registry.npm.taobao.org
- 配置后可通过下面方式来验证是否成功
npm config get registry
- 或
npm info express
3.通过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
- 使用
npm install express
注:如果想还原npm仓库地址,只需再把地址配置成npm镜像就可以了
npm config set registry https://registry.npmjs.org/
更多推荐
已为社区贡献2条内容
所有评论(0)