Node.js:使用nrm来管理npm源

文档

npm切换源

# 设置源
$ npm set registry https://registry.npm.taobao.org/

# 查看npm源
$ npm config ls

使用nrm管理npm源

安装

$ npm install -g nrm

查看帮助

$ nrm -h
Usage: nrm [options] [command]

Options:
  -V, --version                           output the version number
  -h, --help                              output usage information

Commands:
  ls                                      List all the registries
  current [options]                       Show current registry name or URL
  use <registry>                          Change registry to registry
  add <registry> <url> [home]             Add one custom registry
  login [options] <registryName> [value]  Set authorize information for a custom registry with a base64 encoded string or username and pasword
  set-hosted-repo <registry> <value>      Set hosted npm repository for a custom registry to publish packages
  set-scope <scopeName> <value>           Associating a scope with a registry
  del-scope <scopeName>                   Remove a scope
  set [options] <registryName>            Set custom registry attribute
  rename <registryName> <newName>         Set custom registry name
  del <registry>                          Delete one custom registry
  home <registry> [browser]               Open the homepage of registry with optional browser
  publish [options] [<tarball>|<folder>]  Publish package to current registry if current registry is a custom registry.
   if you're not using custom registry, this command will run npm publish directly
  test [registry]                         Show response time for specific or all registries
  help                                    Print this help 
   if you want to clear the NRM configuration when uninstall you can execute "npm uninstall nrm -g -C or npm uninstall nrm -g --clean"

使用

# 查看源列表
$ nrm ls

  npm ---------- https://registry.npmjs.org/
  yarn --------- https://registry.yarnpkg.com/
  tencent ------ https://mirrors.cloud.tencent.com/npm/
  cnpm --------- https://r.cnpmjs.org/
  taobao ------- https://registry.npmmirror.com/
  npmMirror ---- https://skimdb.npmjs.com/registry/


# 使用源
$ nrm use cnpm
Registry has been set to: https://r.cnpmjs.org/

参考
nrm详解

猜你喜欢

转载自blog.csdn.net/mouday/article/details/126460608