daily-share icon indicating copy to clipboard operation
daily-share copied to clipboard

nrm、yrm 包管理器-如何使用npm切换源(2021-9-23)

Open yaogengzhu opened this issue 3 years ago • 0 comments

yrm -- Yarn Registry Manager

管理所有的yarn包的下载源Registry

yrm可以帮助你轻松地添加、删除、查询、切换所有的Yarn Registries,目前内置npm,taobao,yarn三个源

Install

$ npm install -g yrm

Example

列出所有Registry

$ yrm ls
或者
$ yrm list

* npm     -  https://registry.npmjs.org/
  taobao  -  https://registry.npm.taobao.org/
  yarn    -  https://registry.yarnpkg.com/

列出当前正在使用的源(-n, --npm 同步显示npm使用的源)

$ yrm now
// 或者
$ yrm use now -n

切换源(-n, --npm 同时切换npm的源)

$ yrm use yarn

添加源

$ yrm add swb https://registry.npmjs.org/ https://www.npmjs.org

You have added swb successfully!

   [swb](https://registry.npmjs.org/)

删除源(-n, --npm 如果需要修改当前源,同步修改npm的源)

当删除的源正在使用时会指定 yarn 的官方源

$ yrm del swb

Usage

$ yrm help

Usage: yrm [options] [command]


  Options:

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


  Commands:

    list|ls                       列出所有的yarn源
    now [options]                 显示当前使用的源
    use [options] <name>          切换当前的源
    add <name> <registry> [home]  添加yarn源
    del [options] <name>          删除yarn源,当删除的源正在使用时会指定 yarn 的官方源
    help                          打印出yrm的命令帮助信息

nrm 使用方式

选项:  -V, --version                           输出版本号  -h, --help                              输出帮助信息指令:  ls                                      列出所有注册表  current                                 显示当前注册表名称  use <registry>                          切换注册表  add <registry> <url> [home]             添加一个自定义注册表  set-auth [options] <registry> [value]   使用base64编码的字符串或用户名和密码设置自定义注册表的授权信息  set-email <registry> <value>            为自定义注册表设置电子邮件  set-hosted-repo <registry> <value>      设置用于自定义注册表的托管npm存储库以发布程序包  del <registry>                          删除一个自定义注册表  home <registry> [browser]               使用可选的浏览器打开注册表的主页  publish [options] [<tarball>|<folder>]  如果当前注册表是自定义注册表,则将程序包发布到当前注册表。                                          如果您不使用自定义注册表,则此命令将直接运行npm publish  test [registry]                         显示特定或所有注册表的响应时间,一般厕所使用  help                                    打印此帮助

npm 切换源

  • 查看当前是用的源

    npm config get registry
    
  • 设置一个源

    npm config set registry https://registry.npm.taobao.org/
    

yaogengzhu avatar Sep 23 '21 08:09 yaogengzhu