切换淘宝镜像

自带的NPM被墙,最好用国内镜像,由taobao提供,输入如下代码安装cnpm

$ npm install -g cnpm --registry=https://registry.npm.taobao.org
//安装完后查看版本
$ cnpm -v
//成功后会有版本信息返回,不成功有可能是node版本低
  • 1
  • 2
  • 3
  • 4

成功安装后,直接用cnpm代替之前的npm 
安装模块

$ cnpm install [name]
  • 1

同步模块 
直接通过 sync 命令马上同步一个模块, 只有 cnpm 命令行才有此功能:

$ cnpm sync connect
  • 1

其它命令 
支持 npm 除了 publish 之外的所有命令, 如:

$ cnpm info connect
  • 1

更新cnpm或npm

$ cnpm update -g
$ npm update -g
原文地址:https://www.cnblogs.com/fdxxiaobai/p/7940961.html