Oracle Linux 9 (CentOS Stream 9) 安装 node.js 20

Oracle Linux 的 node 默认版本为 16,运行dnf update也无法改变大版本,还需要进行额外操作[1](#1)

  1. 查看支持的版本

    bash 复制代码
    sudo dnf module list nodejs

    输出如下

    复制代码
    Last metadata expiration check: 3:37:22 ago on Fri 11 Oct 2024 09:08:18 PM JST.
    Oracle Linux 9 Application Stream Packages (x86_64)
    Name                Stream              Profiles                                           Summary
    nodejs              18                  common [d], development, minimal, s2i              Javascript runtime
    nodejs              20                  common [d], development, minimal, s2i              Javascript runtime
    
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
  2. 启用 20 版本

    bash 复制代码
    sudo dnf module -y enable nodejs:20

    输出如下

    复制代码
    Last metadata expiration check: 3:40:19 ago on Fri 11 Oct 2024 09:08:18 PM JST.
    Dependencies resolved.
    ==========================================================================================================================
     Package                      Architecture                Version                      Repository                    Size
    ==========================================================================================================================
    Enabling module streams:
     nodejs                                                   20
    
    Transaction Summary
    ==========================================================================================================================
    
    Complete!
  3. 正常升级

    bash 复制代码
    sudo dnf update

    输出如下,可见已成功找到新版。

    复制代码
    Last metadata expiration check: 3:41:36 ago on Fri 11 Oct 2024 09:08:18 PM JST.
    Dependencies resolved.
    ==========================================================================================================================
     Package                Architecture Version                                                    Repository           Size
    ==========================================================================================================================
    Upgrading:
     nodejs                 x86_64       1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0                  ol9_appstream        14 M
     nodejs-docs            noarch       1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0                  ol9_appstream       9.0 M
     nodejs-full-i18n       x86_64       1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0                  ol9_appstream       8.4 M
     npm                    x86_64       1:10.8.1-1.20.16.0.1.module+el9.4.0+90390+ec2aa9c0         ol9_appstream       3.6 M
    
    Transaction Summary
    ==========================================================================================================================
    Upgrade  4 Packages
    
    Total download size: 35 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/4): nodejs-docs-20.16.0-1.module+el9.4.0+90390+ec2aa9c0.noarch.rpm                     9.0 MB/s | 9.0 MB     00:00
    (2/4): nodejs-full-i18n-20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64.rpm                6.7 MB/s | 8.4 MB     00:01
    (3/4): nodejs-20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64.rpm                          8.5 MB/s |  14 MB     00:01
    (4/4): npm-10.8.1-1.20.16.0.1.module+el9.4.0+90390+ec2aa9c0.x86_64.rpm                    4.9 MB/s | 3.6 MB     00:00
    --------------------------------------------------------------------------------------------------------------------------
    Total                                                                                      20 MB/s |  35 MB     00:01
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                                                                  1/1
      Upgrading        : nodejs-docs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.noarch                                     1/8
      Upgrading        : nodejs-full-i18n-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64                                2/8
      Upgrading        : npm-1:10.8.1-1.20.16.0.1.module+el9.4.0+90390+ec2aa9c0.x86_64                                    3/8
      Upgrading        : nodejs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64                                          4/8
      Cleanup          : nodejs-1:16.20.2-8.0.1.el9_4.x86_64                                                              5/8
      Cleanup          : npm-1:8.19.4-1.16.20.2.8.0.1.el9_4.x86_64                                                        6/8
      Cleanup          : nodejs-docs-1:16.20.2-8.0.1.el9_4.noarch                                                         7/8
      Cleanup          : nodejs-full-i18n-1:16.20.2-8.0.1.el9_4.x86_64                                                    8/8
      Running scriptlet: nodejs-full-i18n-1:16.20.2-8.0.1.el9_4.x86_64                                                    8/8
      Verifying        : nodejs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64                                          1/8
      Verifying        : nodejs-1:16.20.2-8.0.1.el9_4.x86_64                                                              2/8
      Verifying        : nodejs-docs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.noarch                                     3/8
      Verifying        : nodejs-docs-1:16.20.2-8.0.1.el9_4.noarch                                                         4/8
      Verifying        : nodejs-full-i18n-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64                                5/8
      Verifying        : nodejs-full-i18n-1:16.20.2-8.0.1.el9_4.x86_64                                                    6/8
      Verifying        : npm-1:10.8.1-1.20.16.0.1.module+el9.4.0+90390+ec2aa9c0.x86_64                                    7/8
      Verifying        : npm-1:8.19.4-1.16.20.2.8.0.1.el9_4.x86_64                                                        8/8
    
    Upgraded:
      nodejs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64
      nodejs-docs-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.noarch
      nodejs-full-i18n-1:20.16.0-1.module+el9.4.0+90390+ec2aa9c0.x86_64
      npm-1:10.8.1-1.20.16.0.1.module+el9.4.0+90390+ec2aa9c0.x86_64
    
    Complete!

  1. CentOS Stream 9 : Node.js インストール : Server World ↩︎
相关推荐
编程贝多芬5 分钟前
Promise 的场景和最佳实践
前端·javascript
Asort6 分钟前
JavaScript 从零开始(四):基础语法详解——从变量声明到数据类型的完全指南
前端·javascript
木木jio9 分钟前
前端大文件分片上传 —— 基于 React 的工程化实现
前端·javascript
轻松Ai享生活12 分钟前
5 节课深入学习Linux Cgroups
linux
Lotzinfly12 分钟前
12个TypeScript奇淫技巧你需要掌握😏😏😏
前端·javascript·面试
一个大苹果13 分钟前
setTimeout延迟超过2^31立即执行?揭秘JavaScript定时器的隐藏边界
javascript
普郎特28 分钟前
"不再迷惑!用'血缘关系'彻底搞懂JavaScript原型链机制"
前端·javascript
christine-rr1 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
一枚前端小能手1 小时前
「周更第3期」实用JS库推荐:Lodash
前端·javascript
艾小码1 小时前
Vue组件到底怎么定义?全局注册和局部注册,我踩过的坑你别再踩了!
前端·javascript·vue.js