Rocky_Linux_8
Sponsored Link

Node.js 12 : Install2021/08/02

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

Rocky Linux 8 - AppStream
Name      Stream    Profiles                                Summary
nodejs    10 [d]    common [d], development, minimal, s2i   Javascript runtime
nodejs    12        common [d], development, minimal, s2i   Javascript runtime
nodejs    14        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:12
# specify Node.js 12 and install

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

Dependencies resolved.
=============================================================================================
 Package            Arch    Version                                          Repo        Size
=============================================================================================
Upgrading:
 nodejs             x86_64  1:12.21.0-1.module+el8.3.0+99+3663d81c           appstream   10 M
 nodejs-full-i18n   x86_64  1:12.21.0-1.module+el8.3.0+99+3663d81c           appstream  7.5 M
 npm                x86_64  1:6.14.11-1.12.21.0.1.module+el8.3.0+99+3663d81c appstream  3.7 M
Installing weak dependencies:
 nodejs-docs        noarch  1:12.21.0-1.module+el8.3.0+99+3663d81c           appstream  4.1 M
Installing module profiles:
 nodejs/common

Transaction Summary
=============================================================================================
Install  1 Package
Upgrade  3 Packages
.....
.....

[root@dlp ~]#
node -v

v12.21.0

# 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] 30448
[root@dlp ~]#
curl localhost:8080

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

Matched Content