Welcome

首页 / 脚本样式 / Nodejs / npm 设置国内镜像源

npm 设置国内镜像源

1.说明

刚安装的npm使用默认的源会感觉特别特别慢,所以,非常有必要使用国内的源,比如说众所周知的淘宝镜像源

2.全局设置

查看当前源

npm config get registry

设置为淘宝源

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

# 还原默认源:npm config set registry https://registry.npmjs.org/

3.临时使用

上面那种设置是全局的,以后每次都会自动读取已经设置好的源,如果只是一次性使用,可以使用下面的命令

npm --registry https://registry.npm.taobao.org install XXX(模块名)

4.使用cnpm

cnpm是一个命令,用它来代替npm

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

cnpm install XXX(模块名)

5.使用nrm

npm install -g nrm

nrm use taobao

nrm ls  # 查看当前可用源命令