國內npm鏡像使用方法


npm全稱Node Package Manager,是node.js的模塊依賴管理工具。由於npm的源在國外,所以國內用戶使用起來各種不方便。下面整理出了一部分國內優秀的npm鏡像資源,國內用戶可以選擇使用。

淘寶npm鏡像

搜索地址:http://npm.taobao.org/
registry地址:http://registry.npm.taobao.org/

cnpmjs鏡像

搜索地址:http://cnpmjs.org/
registry地址:http://r.cnpmjs.org/

使用方法:

有很多方法來配置npm的registry地址,下面根據不同情境列出幾種比較常用的方法。以淘寶npm鏡像舉例:

1、臨時使用

npm --registry https://registry.npm.taobao.org install express

2、持久使用

npm config set registry https://registry.npm.taobao.org // 配置后可通過下面方式來驗證是否成功 npm config get registry // 或 npm info express

3、通過cnpm使用

npm install -g cnpm --registry=https://registry.npm.taobao.org // 使用 cnpm install express


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM