此文列出常見npm命令锁摔,大家共勉巡验。
1.查看npm源地址
npm config list
結(jié)果:
metrics-registry = "http://registry.npm.taobao.org/"
2.修改registry地址际插,比如修改為淘寶鏡像源。
npm set registry https://registry.npm.taobao.org/
如果有一天你肉身FQ到國外显设,用不上了框弛,用rm命令刪掉它
npm config rm registry
3.nrm 是專門用來管理和快速切換私人配置的 registry
建議全局安裝
npm install nrm -g --save
用nrm ls
命令查看默認(rèn)配置,帶*號即為當(dāng)前使用的配置
nrm ls
npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
rednpm - http://registry.mirror.cqupt.edu.cn/
npmMirror https://skimdb.npmjs.com/registry/
edunpm - http://registry.enpmjs.org/
也可以直接輸入以下命令查看當(dāng)前使用的是哪個源
nrm current
切換源
nrm use cnpm
用nrm add 命令添加公司私有npm源捕捂,如http://registry.npm.360.org(瑟枫,起個別名叫qihoo
nrm add qihoo http://registry.npm.360.org
測試下速度
nrm test npm
輸出
npm ---- 790ms
最后,如果你被公司開除了指攒,怒刪公司npm源配置
nrm del qihoo
4.更新Node
版本和npm
版本
清除node的cache(清除node的緩存慷妙,這個看情況而定,不是必須的)
sudo npm cache clean -f
安裝"n"版本管理工具允悦,管理node(沒有錯膝擂,就是n)
sudo npm install -g n
更新node版本
sudo npm install npm@latest -g
再查一遍本機當(dāng)前Node和npm的版本吧
node -v
npm -v