npm切换源

504 阅读1分钟

开始

由于 npm 服务器在国外,服务器响应相对有延迟,所以我们可以将其切换到国内的淘宝镜像源

查看原版本的镜像地址

npm get registry

    https://registry.npmjs.org/  # 这个是官方镜像网址

修改镜像地址

我们普遍使用淘宝镜像地址

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

修改 npm 为 cnpm

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

换回原来的镜像

如有需要,可将 镜像通过下列方式更换

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