CentOS Stream 9
Sponsored Link

Node.js 20 : Install2023/10/13

Install Node.js 20.
[1] Confirm the current enabled version of Node.js and Install version 20.
[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

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:20
# specify Node.js 20 and install

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

Dependencies resolved.
 Package            Arch    Version                                    Repo        Size
Installing group/module packages:
 nodejs             x86_64  1:20.5.1-1.module_el9+642+c81e94f6         appstream   14 M
 npm                x86_64  1:9.8.0- appstream  2.6 M
Installing weak dependencies:
 nodejs-docs        noarch  1:20.5.1-1.module_el9+642+c81e94f6         appstream  8.0 M
 nodejs-full-i18n   x86_64  1:20.5.1-1.module_el9+642+c81e94f6         appstream  8.5 M
Installing module profiles:

Transaction Summary
Install  4 Packages

[root@dlp ~]#
node -v


# 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");

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

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

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

Matched Content