CentOS Stream 8
Sponsored Link

Node.js 16 : Install2021/09/23

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

CentOS Stream 8 - AppStream
Name     Stream      Profiles                                Summary
nodejs   10 [d][e]   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
nodejs   16          common, 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 reset nodejs

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

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

Dependencies resolved.
============================================================================================
 Package            Arch    Version                                         Repo        Size
============================================================================================
Upgrading:
 nodejs             x86_64  1:16.7.0-2.module_el8.5.0+917+002e3877          appstream   12 M
 nodejs-full-i18n   x86_64  1:16.7.0-2.module_el8.5.0+917+002e3877          appstream  7.6 M
 npm                x86_64  1:7.20.3-1.16.7.0.2.module_el8.5.0+917+002e3877 appstream  2.4 M
Installing weak dependencies:
 nodejs-docs        noarch  1:16.7.0-2.module_el8.5.0+917+002e3877          appstream  8.5 M
Installing module profiles:
 nodejs/common

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

[root@dlp ~]#
node -v

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

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

Matched Content