10月06, 2016

如何提升npm下载速度

默认情况下,利用npm install下载资源时,默认会从npm官方进行下载。由于服务器在国外,所以速度会慢很多。我们可以将npm的下资源指向淘宝npm源来提高下载速度。

C:\Users\lzhao>npm config get registry
https://registry.npmjs.org/

C:\Users\lzhao>npm config set registry http://registry.npm.taobao.org/

C:\Users\lzhao>npm config get registry
http://registry.npm.taobao.org/

C:\Users\lzhao>

当然,我们也可以下载nrm这个工具更快速地切换下载源。

C:\Users\lzhao>npm install -g nrm
C:\Users\lzhao>nrm ls

* npm ---- https://registry.npmjs.org/
  cnpm --- http://r.cnpmjs.org/
  taobao - http://registry.npm.taobao.org/
  edunpm - http://registry.enpmjs.org/
  eu ----- http://registry.npmjs.eu/
  au ----- http://registry.npmjs.org.au/
  sl ----- http://npm.strongloop.com/
  nj ----- https://registry.nodejitsu.com/
  pt ----- http://registry.npmjs.pt/
  tcl ---- http://npm.tcl.com:8000/


C:\Users\lzhao>nrm use taobao

   Registry has been set to: http://registry.npm.taobao.org/

C:\Users\lzhao>nrm ls

  npm ---- https://registry.npmjs.org/
  cnpm --- http://r.cnpmjs.org/
* taobao - http://registry.npm.taobao.org/
  edunpm - http://registry.enpmjs.org/
  eu ----- http://registry.npmjs.eu/
  au ----- http://registry.npmjs.org.au/
  sl ----- http://npm.strongloop.com/
  nj ----- https://registry.nodejitsu.com/
  pt ----- http://registry.npmjs.pt/
  tcl ---- http://npm.tcl.com:8000/

C:\Users\lzhao>

本文链接:http://www.asyncoder.com//post/how-to-imporve-npm-download-speed.html

-- EOF --

Comments