npm源切换、管理nrm

npm

  • 查看源:
npm config get registry
  • 永久切换源、设置源
npm config set registry https://xxxxxxxx
  • 临时使用源
npm i xx  --registry https://xxxxxxx
  • 查看全局安装的包
npm list -g --depth 0
  • 安装指定版本/最新版本
npm i <module name>@1.0.0         //安装指定版本的模块
npm i <module name>@latest 		  //最新
  • 安装位置:
npm root -g   //查看全局node_modules路径
npm root      //查看本地node_modules路径
  • 清理缓存后重新安装(适用:依赖缺失重新安装)
npm cache clean --force
npm install xxx
  • 当某个依赖安装失败,可忽略后单独安装
npm install xxx@0.1.21 --ignore-scripts
npm i xxx@0.1.21

一些后缀:
-S, --save 安装包信息将加入到dependencies(生产阶段的依赖)
-D, --save-dev 安装包信息将加入到devDependencies(开发阶段的依赖),所以开发阶段一般使用它
-O, --save-optional 安装包信息将加入到optionalDependencies(可选阶段的依赖)
-E, --save-exact 精确安装指定模块版本
-P, --save-prod, 添加dependencies 里面所有的包
官方源:
https://registry.npmjs.org/
淘宝源:
https://registry.npm.taobao.org

nrm的使用

安装nrm:sudo npm install -g nrm
查看是否安装成功:nrm --version

查看源列表:nrm ls

~ 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/

使用源 nrm use xxx

添加源nrm add registryname url
删除源:nrm del registryname

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值