設置npm源的幾種方式

設置npm源的幾種方式

原始源

# the original source
https://registry.npmjs.org/

方案: 使用nrm

  • 安裝
npm install -g nrm
  • 列出源的候選項
nrm ls

輸出結果:

* npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/
  • 使用淘寶源
nrm use taobao

方案: 改變全局的註冊

  • 設置成淘寶源
npm config set registry https://registry.npm.taobao.org
  • 查看結果
npm config get registry

輸出結果:

https://registry.npm.taobao.org/
  • 測試一下
npm info underscore

方案: 在命令行裏指定源

npm --registry https://registry.npm.taobao.org install [name]

方案: 修改 ~/.npmrc

registry = https://registry.npm.taobao.org

方案: 使用cnpm

npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install [name]

參照

淘寶源鏈接

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章