跳至主要內容

NPM 源设置和管理方法

Yihui小于 1 分钟

NPM 源设置和管理方法

常见镜像源

淘宝npm镜像

cnpmjs镜像

源切换

临时使用

npm install express --registry=https://registry.npm.taobao.org

临时指定安装包的源,并将源地址作为参数传入

全局切换

方式一:设置源地址并持久使用

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

校验是否生效:

npm config get registry

方式二:切换为cnpm

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

安装方式改为:

cnpm install express

校验cnpm源:

cnpm config get registry

还原

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