AdSense

網頁

2024/2/21

Rocky Linux 安裝Node.js

參考Node.js官方文件即可。


安裝環境:

  • Rocky Linux 9


安裝

這邊使用dnf(Dandified Yum)套件管理工具安裝。

輸入dnf module list nodejs檢視可安裝版本(Stream)。

]# dnf module list nodejs
Last metadata expiration check: 1:49:59 ago on Wed 21 Feb 2024 02:01:50 PM CST.
Rocky Linux 9 - AppStream
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

輸入dnf module install nodejs:<stream>/<profile>安裝,例如這邊輸入dnf module install nodejs:18/common安裝版本18的common package。

# dnf module install nodejs:18/common
Last metadata expiration check: 1:54:22 ago on Wed 21 Feb 2024 02:01:50 PM CST.
Dependencies resolved.
================================================================================================================================================================================================================================================================================
 Package                                                       Architecture                                        Version                                                                                         Repository                                              Size
================================================================================================================================================================================================================================================================================
Installing group/module packages:
 nodejs                                                        x86_64                                              1:18.18.2-2.module+el9.3.0+15867+4ff8d002                                                       appstream                                               13 M
 npm                                                           x86_64                                              1:9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002                                               appstream                                              2.0 M
Installing weak dependencies:
 nodejs-docs                                                   noarch                                              1:18.18.2-2.module+el9.3.0+15867+4ff8d002                                                       appstream                                              7.6 M
 nodejs-full-i18n                                              x86_64                                              1:18.18.2-2.module+el9.3.0+15867+4ff8d002                                                       appstream                                              8.5 M
Installing module profiles:
 nodejs/common
Enabling module streams:
 nodejs                                                                                                            18

Transaction Summary
================================================================================================================================================================================================================================================================================
Install  4 Packages

Total download size: 31 M
Installed size: 168 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): npm-9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002.x86_64.rpm                                                                                                                                                                           4.3 MB/s | 2.0 MB     00:00
(2/4): nodejs-full-i18n-18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64.rpm                                                                                                                                                                      8.2 MB/s | 8.5 MB     00:01
(3/4): nodejs-18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64.rpm                                                                                                                                                                                 10 MB/s |  13 MB     00:01
(4/4): nodejs-docs-18.18.2-2.module+el9.3.0+15867+4ff8d002.noarch.rpm                                                                                                                                                                           9.0 MB/s | 7.6 MB     00:00
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                                                            17 MB/s |  31 MB     00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                                                        1/1
  Installing       : nodejs-docs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.noarch                                                                                                                                                                                           1/4
  Installing       : nodejs-full-i18n-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                      2/4
  Installing       : nodejs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                                3/4
  Installing       : npm-1:9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                           4/4
  Running scriptlet: npm-1:9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                           4/4
  Verifying        : npm-1:9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                           1/4
  Verifying        : nodejs-full-i18n-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                      2/4
  Verifying        : nodejs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64                                                                                                                                                                                                3/4
  Verifying        : nodejs-docs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.noarch                                                                                                                                                                                           4/4

Installed:
  nodejs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64       nodejs-docs-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.noarch       nodejs-full-i18n-1:18.18.2-2.module+el9.3.0+15867+4ff8d002.x86_64       npm-1:9.8.1-1.18.18.2.2.module+el9.3.0+15867+4ff8d002.x86_64

Complete!

安裝完輸入node -v顯示版本資訊即代表安裝成功。

# node -v
v18.18.2

當然npm也一併安裝了。

# npm -v
9.8.1

沒有留言:

AdSense