文章永久连接:https://tech.souyunku.com/?p=5426
大家都知道国内直接使用 npm 的官方镜像是非常慢的,这里推荐使用淘宝 NPM 镜像
淘宝 NPM 镜像是一个完整 npmjs.org 镜像,可以用来代替官方版本(只读),同步频率目前为 10 分钟 一次以保证尽量与官方服务同步
我们可以使用淘宝定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm
安装 cnpm
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
然后就可以使用 cnpm 命令来安装模块了
$ cnpm install [name]
npm –registry
当然,我们也可以不安装 cnpm 而直接使用 npm
只要加上 --registry=https://registry.npm.taobao.org
属性即可
比如安装 express 可以使用下面的命令
$ npm install express --registry=https://registry.npm.taobao.org
更多信息可以查阅: http://npm.taobao.org/
干货推荐
附录:Node.js 教程:系列文章
- 一、Node.js 基础教程
- 二、Node.js 环境配置
- 三、Node.js 创建第一个应用
- 四、Node.js NPM 使用介绍
- 【当前读到】五、Node.js 使用淘宝 NPM 镜像
- 六、Node.js REPL ( 交互式解释器 )
- 七、Node.js 回调函数
- 八、Node.js 事件循环
- 九、Node.js EventEmitter
- 十、Node.js Buffer(缓冲区)
- 十一、Node.js Stream (流)
- 十二、Node.js 模块系统
- 十三、Node.js 函数
- 十四、Node.js 开发 URL 路由
- 十五、Node.js 全局对象
- 十六、Node.js 常用工具
- 十七、Node.js 文件系统( fs 模块 )
- 十八、Node.js GET-POST 请求
- 十九、Node.js 内置模块
- 二十、Node.js WEB 模块
- 二十一、Node.js Express 框架
- 二十二、Node.js RESTful API
- 二十三、Node.js 多进程
- 二十四、Node.js JXcore 打包
- 二十五、Node.js 访问 MySQL 数据库
- 二十六、Node.js 访问 MongoDB
- 二十七、Node.js OS 模块
- 二十八、Node.js DNS 模块
- 二十九、Node.js Domain 模块
- 三十、Node.js Path 模块
- 三十一、Node.js Net 模块