标签: 插件

淘宝 npm 地址:http://npm.taobao.org/

如何使用

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

1. 临时使用

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

2. 持久使用

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

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

npm config get registry

npm info express

3. 通过 cnpm 使用

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

使用

cnpm install express

首先打开命令行终端 , 然后输入

npm config ls

这时你应该可以看到一个 prefix 属性 , 它表明了 npm 包的默认安装位置 , 因此可以通
过改这个配置修改包安装位置 . 具体的命令如下 :

npm config set prefix "your node_global path"

把引号内的内容改为你所希望的路径即可 . 比如我 :

npm config ls;

npm config set prefix "D:\configuration\nodeconfig\npm"

npm config set cache "D:\configuration\nodeconfig\npm-cache"