百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术分类 > 正文

包管理如何切换源(nrm用法详情和yrm 用法详情)

ztj100 2024-11-17 18:13 38 浏览 0 评论

关键字:npm、nrm、yarn、yrm

混迹IT多年的资深后端开发者及项目管理者,欢迎学术沟通,其他合作

目录

npm镜像源

1、查看当前使用的镜像源

2、修改镜像源

yarn镜像源

1、查看当前使用的镜像源

2、修改镜像源

npm镜像源

因为 npm 默认的源是在国外,我们访问时会比较慢,一般都会使用淘宝的镜像,或者有些有公司自己的镜像,这就涉及到切换源的操作,总结一下这些操作。

1、查看当前使用的镜像源

npm config get registry

2、修改镜像源

方式1:npm命令修改

npm config set registry https://registry.npmmirror.com/

方式2: 第三方工具nrm管理镜像源(推荐)

nrm可以帮助你轻松地添加、删除、查询、切换所有的Yarn Registries

安装 nrm:

npm install -g nrm

列出所有镜像源:

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 taobao
SUCCESS The registry has been changed to 'taobao'.

新增镜像:

nrm add aliyun http://maven.aliyun.com/nexus/content/groups/public

删除镜像:

nrm del taobao

测试延迟(访问速度):

yrm test aliyun

查看帮助:

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

Options:
  -V, --version                    output the version number
  -h, --help                       display help for command

Commands:
  ls                               List all the registries
  current [options]                Show current registry name or URL
  use <name>                       Change current registry
  add <name> <url> [home]          Add custom registry
  login [options] <name> [base64]  Set authorize information for a custom registry with a base64 encoded string or username
                                   and password
  set-hosted-repo <name> <repo>    Set hosted npm repository for a custom registry to publish package
  set-scope <scopeName> <url>      Associating a scope with a registry
  del-scope <scopeName>            Remove a scope
  set [options] <name>             Set a custom registry attribute
  rename <name> <newName>          Change custom registry name
  del <name>                       Delete custom registry
  home <name> [browser]            Open the homepage of registry with optional browser
  test [registry]                  Show response time for specific or all registries
  help [command]                   display help for command


yarn镜像源

执行命令时,yarn 默认是去 npm/yarn 官方镜像源(国外)获取资源,所以速度较慢甚至不可用,解决该问题需要修改默认配置为国内镜像。

1、查看当前使用的镜像源

yarn config get registry

2、修改镜像源

方式1:yarn命令修改

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

方式2: 第三方工具yrm管理镜像源(推荐)

yrm可以帮助你轻松地添加、删除、查询、切换所有的Yarn Registries

安装 yrm:

npm install -g yrm

列出所有镜像源:

yrm 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/
  yarn --- https://registry.yarnpkg.com
  aliyun - http://maven.aliyun.com/nexus/content/groups/public/


切换镜像:

yrm use taobao
   YARN Registry has been set to: https://registry.npm.taobao.org/

   NPM Registry has been set to: https://registry.npm.taobao.org/

新增镜像:

yrm add aliyun http://maven.aliyun.com/nexus/content/groups/public

删除镜像:

yrm del taobao

测试延迟(访问速度):

yrm test aliyun

查看帮助:

yrm -h
Usage: cli [options] [command]

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

Commands:
  ls                           List all the registries
  current                      Show current registry name
  use <registry>               Change registry to registry
  add <registry> <url> [home]  Add one custom registry
  del <registry>               Delete one custom registry
  home <registry> [browser]    Open the homepage of registry with optional browser
  test [registry]              Show response time for specific or all registries
  help                         Print 

相关推荐

如何将数据仓库迁移到阿里云 AnalyticDB for PostgreSQL

阿里云AnalyticDBforPostgreSQL(以下简称ADBPG,即原HybridDBforPostgreSQL)为基于PostgreSQL内核的MPP架构的实时数据仓库服务,可以...

Python数据分析:探索性分析

写在前面如果你忘记了前面的文章,可以看看加深印象:Python数据处理...

CSP-J/S冲奖第21天:插入排序

...

C++基础语法梳理:算法丨十大排序算法(二)

本期是C++基础语法分享的第十六节,今天给大家来梳理一下十大排序算法后五个!归并排序...

C 语言的标准库有哪些

C语言的标准库并不是一个单一的实体,而是由一系列头文件(headerfiles)组成的集合。每个头文件声明了一组相关的函数、宏、类型和常量。程序员通过在代码中使用#include<...

[深度学习] ncnn安装和调用基础教程

1介绍ncnn是腾讯开发的一个为手机端极致优化的高性能神经网络前向计算框架,无第三方依赖,跨平台,但是通常都需要protobuf和opencv。ncnn目前已在腾讯多款应用中使用,如QQ,Qzon...

用rust实现经典的冒泡排序和快速排序

1.假设待排序数组如下letmutarr=[5,3,8,4,2,7,1];...

ncnn+PPYOLOv2首次结合!全网最详细代码解读来了

编辑:好困LRS【新智元导读】今天给大家安利一个宝藏仓库miemiedetection,该仓库集合了PPYOLO、PPYOLOv2、PPYOLOE三个算法pytorch实现三合一,其中的PPYOL...

C++特性使用建议

1.引用参数使用引用替代指针且所有不变的引用参数必须加上const。在C语言中,如果函数需要修改变量的值,参数必须为指针,如...

Qt4/5升级到Qt6吐血经验总结V202308

00:直观总结增加了很多轮子,同时原有模块拆分的也更细致,估计为了方便拓展个管理。把一些过度封装的东西移除了(比如同样的功能有多个函数),保证了只有一个函数执行该功能。把一些Qt5中兼容Qt4的方法废...

到底什么是C++11新特性,请看下文

C++11是一个比较大的更新,引入了很多新特性,以下是对这些特性的详细解释,帮助您快速理解C++11的内容1.自动类型推导(auto和decltype)...

掌握C++11这些特性,代码简洁性、安全性和性能轻松跃升!

C++11(又称C++0x)是C++编程语言的一次重大更新,引入了许多新特性,显著提升了代码简洁性、安全性和性能。以下是主要特性的分类介绍及示例:一、核心语言特性1.自动类型推导(auto)编译器自...

经典算法——凸包算法

凸包算法(ConvexHull)一、概念与问题描述凸包是指在平面上给定一组点,找到包含这些点的最小面积或最小周长的凸多边形。这个多边形没有任何内凹部分,即从一个多边形内的任意一点画一条线到多边形边界...

一起学习c++11——c++11中的新增的容器

c++11新增的容器1:array当时的初衷是希望提供一个在栈上分配的,定长数组,而且可以使用stl中的模板算法。array的用法如下:#include<string>#includ...

C++ 编程中的一些最佳实践

1.遵循代码简洁原则尽量避免冗余代码,通过模块化设计、清晰的命名和良好的结构,让代码更易于阅读和维护...

取消回复欢迎 发表评论: