npm 更改为淘宝镜像的方法

来源:互联网 发布:简单json格式 编辑:程序博客网 时间:2024/05/13 08:38

npm 更改为淘宝镜像的方法


1、命令行临时使用指定镜像(淘宝)

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


2、命令行永久更改使用指定镜像(淘宝)

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

以后 npm install express 默认使用指定(淘宝)镜像


3、通过npm配置文件直接修改,本质和第2条一样,配置文件位置(windows环境)为C盘下的.npmrc文件(百度很容易查到文件路径),MAC没试过。


4、使用淘宝 NPM 镜像(参考 http://www.runoob.com/nodejs/nodejs-npm.html)

命令行输入 npm install-g cnpm--registry=https://registry.npm.taobao.org

这样就可以使用 cnpm 命令来安装模块了: cnpm installexpress


查看目前使用的npm镜像的方法:

npm config get registry