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

发布于:2024-10-13 ⋅ 阅读:(9) ⋅ 点赞:(0)

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

  1. 查看支持的版本

    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 版本

    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. 正常升级

    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 ↩︎