CentOS 8.3 上如何安装yarn

一.安装源下载

[root@192 ~]# sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo
--2021-11-18 17:11:40--  https://dl.yarnpkg.com/rpm/yarn.repo
正在解析主机 dl.yarnpkg.com (dl.yarnpkg.com)... 104.16.171.99, 104.18.126.100, 2606:4700::6812:7e64, ...
正在连接 dl.yarnpkg.com (dl.yarnpkg.com)|104.16.171.99|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:130 [application/octet-stream]
正在保存至: “/etc/yum.repos.d/yarn.repo”

/etc/yum.repos.d/yarn.repo                   100%[============================================================================================>]     130  --.-KB/s  用时 0s      

2021-11-18 17:11:48 (50.7 MB/s) - 已保存 “/etc/yum.repos.d/yarn.repo” [130/130])

命令运行结果

二.安装库包

[root@192 ~]# sudo yum install yarn
Yarn Repository                                                                                                                                    45 kB/s | 365 kB     00:08    
上次元数据过期检查:0:00:01 前,执行于 2021年11月18日 星期四 17时12分09秒。
依赖关系解决。
==================================================================================================================================================================================
 软件包                                架构                        版本                                                                      仓库                            大小
==================================================================================================================================================================================
安装:
 yarn                                  noarch                      1.22.15-1                                                                 yarn                           1.2 M
安装依赖关系:
 nodejs                                x86_64                      1:10.24.0-1.module_el8.3.0+717+fa496f1d                                   appstream                      8.8 M
 npm                                   x86_64                      1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d                         appstream                      3.7 M
安装弱的依赖:
 nodejs-full-i18n                      x86_64                      1:10.24.0-1.module_el8.3.0+717+fa496f1d                                   appstream                      7.3 M
启用模块流:
 nodejs                                                            10                                                                                                            

事务概要
==================================================================================================================================================================================
安装  4 软件包

总下载:21 M
安装大小:76 M
确定吗?[y/N]: y
下载软件包:
(1/4): npm-6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                                             1.1 MB/s | 3.7 MB     00:03    
(2/4): nodejs-full-i18n-10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                                          1.2 MB/s | 7.3 MB     00:06    
(3/4): nodejs-10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64.rpm                                                                                    1.3 MB/s | 8.8 MB     00:06    
(4/4): yarn-1.22.15-1.noarch.rpm                                                                                                                   73 kB/s | 1.2 MB     00:16    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                              1.0 MB/s |  21 MB     00:20     
警告:/var/cache/dnf/yarn-39eb54bf733530c3/packages/yarn-1.22.15-1.noarch.rpm: 头V4 RSA/SHA512 Signature, 密钥 ID 6963f07f: NOKEY
Yarn Repository                                                                                                                                   713  B/s | 1.6 kB     00:02    
导入 GPG 公钥 0x6963F07F:
 Userid: "Yarn RPM Packaging <yarn@dan.cx>"
 指纹: 9A6F 73F3 4BEB 7473 4D8C 6914 9CBB B558 6963 F07F
 来自: https://dl.yarnpkg.com/rpm/pubkey.gpg
 确定吗?[y/N]: y
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  运行脚本: npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                      1/1 
  准备中  :                                                                                                                                                                   1/1 
  安装    : nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                   1/4 
  安装    : npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                      2/4 
  安装    : nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                             3/4 
  安装    : yarn-1.22.15-1.noarch                                                                                                                                             4/4 
  运行脚本: yarn-1.22.15-1.noarch                                                                                                                                             4/4 
  验证    : nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                             1/4 
  验证    : nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                   2/4 
  验证    : npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                                                                                                      3/4 
  验证    : yarn-1.22.15-1.noarch                                                                                                                                             4/4 

已安装:
  nodejs-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                                  nodejs-full-i18n-1:10.24.0-1.module_el8.3.0+717+fa496f1d.x86_64                          
  npm-1:6.14.11-1.10.24.0.1.module_el8.3.0+717+fa496f1d.x86_64                           yarn-1.22.15-1.noarch                                                                    

完毕!

在这里插入图片描述

三.安装完后查看版本

[root@192 ~]# yarn --version
1.22.15
[root@192 ~]# 

在这里插入图片描述