国内使用 npm 速度很慢,使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:
npm install -g cnpm --registry=registry.npmmirror.com
npm config set registry registry.npmmirror.com (是一个 npm 配置命令,用于将 npm 的包下载源(registry)设置为国内镜像地址)
查看当前源:
npm config get registry
执行后若返回 https://registry.npmmirror.com 即表示修改成功。
恢复默认源:
npm config set registry registry.npmjs.org
设置新源
npm config set registry registry.npm.taobao.org/