cnpm

cnpm

介绍

安装 NodeJS 之后使用 npm 来安装包使用的是国外的地址,经常会出现超时错误,可以通过修改为国内的淘宝源来加速安装。

配置

临时使用

npm --registry [https://registry.npm.taobao.org](https://registry.npm.taobao.org/) install npm包

永久使用

直接配置

npm config set registry [https://registry.npm.taobao.org](https://registry.npm.taobao.org/)

通过如下命令可以查看是否配置成功

1
2
npm config get registry
npm info express

如果需要恢复成原来的官方地址只需要执行如下命令:

npm config set registry [https://registry.npmjs.org](https://registry.npmjs.org/)

使用 cnpm

安装淘宝的 cnpm,然后在使用时直接将 npm 命令替换成 cnpm 命令即可

npm install -g cnpm --registry=[https://registry.npm.taobao.org](https://registry.npm.taobao.org/)

然后安装时使用如下命令

cnpm install npm包


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!