NPM的一些配置

485 阅读1分钟

查看配置

  • npm config ls or npm config list 所有配置
  • npm config list -l 获取某配置
  • npm config get xxx

配置全局安装和缓存路径

  • npm config set prefix xxxpath
  • npm config set cache xxxpath
windows下要将全局路径添加到环境变量PATH中,方可使用依赖的独有命令

查看全局包

  • npm list -g --depth 0

卸载包

  • npm uninstall

管理工具

CGR

同时或分开管理npm、yarn源的工具,代替nrm😳

  1. 安装
  • npm install -g cgr
  1. 使用
  • 默认源列表: N代表npm,Y代表yarn,*代表npm和yarn共用的源
  • 源切换: y/yarn代表yarn切换,n/npm代表npm切换,大小写均可;type为空,表示同时切换源
  1. 添加私有源
  • cgr add 源name http[s]://xxx
  1. 删除
  • cgr del 源name
  1. 测试
  • cgr test

NRM

  1. 安装
  • npm install -g nrm
  1. 查看所有配置的源
  • nrm ls
  1. 切换源
  • nrm use <registry>
  1. 添加源
  • nrm add registry http[s]://xxx
  1. 删除源
  • nrm del <registry>
  1. 测试响应速度
  • nrm test npm