文章目录
  1. 1. 如何使用
  2. 2. Yarn

npm全称Node Package Manager,是node.js的模块依赖管理工具。由于npm的源在国外,所以国内用户使用起来各种不方便。下面整理出了一部分国内优秀的npm镜像资源,国内用户可以选择使用。

国内优秀npm镜像

如何使用

有很多方法来配置npm的registry地址,下面根据不同情境列出几种比较常用的方法。以淘宝npm镜像举例:

1.临时使用

1
npm --registry https://registry.npmmirror.com install express

2.持久使用

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

// 配置后可通过下面方式来验证是否成功

1
npm config get registry

// 或

1
npm info express

3.通过cnpm使用

1
npm install -g cnpm --registry=https://registry.npmmirror.com

// 使用

1
cnpm install express

Yarn

临时修改

1
yarn save 软件名 --registry https://registry.npmmirror.com

全局修改

1
yarn config set registry https://registry.npmmirror.com

参考: https://www.jianshu.com/p/bd03c4c497c5 https://www.cnblogs.com/zh719588366/p/6784848.html

文章目录
  1. 1. 如何使用
  2. 2. Yarn