CentOS Stream 9
Sponsored Link

Node.js 22 : Install2024/12/04

 

Install Node.js 22.

[1] Confirm the current enabled version of Node.js and Install version 22.
[root@dlp ~]#
dnf module list nodejs

CentOS Stream 9 - AppStream
Name      Stream    Profiles                                Summary
nodejs    18        common [d], development, minimal, s2i   Javascript runtime
nodejs    20        common [d], development, minimal, s2i   Javascript runtime
nodejs    22        common [d], development, minimal, s2i   Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

# if other versions are enabled, reset once and switch to the version

[root@dlp ~]#
dnf module -y reset nodejs

[root@dlp ~]#
dnf module -y enable nodejs:22
# specify Node.js 22 and install

[root@dlp ~]#
dnf module -y install nodejs:22/common

Dependencies resolved.
=========================================================================================
 Package            Arch    Version                                      Repo        Size
=========================================================================================
Installing group/module packages:
 nodejs             x86_64  1:22.4.1-4.module_el9+1103+f54cc21b          appstream  2.1 M
 npm                x86_64  1:10.8.1-1.22.4.1.4.module_el9+1103+f54cc21b appstream  2.4 M
Installing dependencies:
 nodejs-libs        x86_64  1:22.4.1-4.module_el9+1103+f54cc21b          appstream   19 M
Installing weak dependencies:
 nodejs-docs        noarch  1:22.4.1-4.module_el9+1103+f54cc21b          appstream  8.5 M
 nodejs-full-i18n   x86_64  1:22.4.1-4.module_el9+1103+f54cc21b          appstream  8.4 M
Installing module profiles:
 nodejs/common

Transaction Summary
=========================================================================================
Install  5 Packages
.....
.....

[root@dlp ~]#
node -v

v22.4.1

# verify to create test script

[root@dlp ~]# cat > nodejs_test.js <<'EOF' 
var http = require('http');
var server = http.createServer(function(req, res) {
  res.write("Hello, This is the Node.js Simple Web Server!\n");
  res.end();
}).listen(8080);
EOF 

[root@dlp ~]#
node nodejs_test.js &

[1] 1529
[root@dlp ~]#
curl localhost:8080

Hello, This is the Node.js Simple Web Server!
[root@dlp ~]#
kill 1529

Matched Content