Labs-NodeJS Introduction. Q3 : Install nodejs

hi

In Labs - NodeJS introduction Q 3 : Help us install NodeJS 13 on host01 server and there is Hint provided as below

*utline* Hint

Run `curl -sL https://rpm.nodesource.com/setup_13.x | sudo bash -;

sudo yum install -y nodejs`

My doubt is even if we do not execute first command which starts with curl and directly execute 2nd command alone which is " sudo yum install -y nodejs " still we get the nodejs installed and the check also passes .

Q1. Then why do we need first command which starts with " curl " at all ?
Q2. What is difference between curl and wget command and which one is to be used when ?

Please guide.

Below is the output without curl command . Checks also pass at the end of this output


thor@host01 /$ -;sudo yum install -y nodejs
bash: -: command not foundLoaded plugins: fastestmirror, ovl
Determining fastest mirrors
epel/x86_64/metalink                                                                    |  32 kB  00:00:00
 * base: mirror.imt-systems.com
 * epel: mirror.de.leaseweb.net
 * extras: mirror.checkdomain.de
 * updates: mirror.checkdomain.de
base                                                                                    | 3.6 kB  00:00:00
epel                                                                                    | 4.7 kB  00:00:00
extras                                                                                  | 2.9 kB  00:00:00
updates                                                                                 | 2.9 kB  00:00:00
(1/7): epel/x86_64/group_gz                                                             |  95 kB  00:00:00
(2/7): base/7/x86_64/group_gz                                                           | 153 kB  00:00:00
(3/7): base/7/x86_64/primary_db                                                         | 6.1 MB  00:00:00
(4/7): extras/7/x86_64/primary_db                                                       | 222 kB  00:00:00(5/7): epel/x86_64/updateinfo                                                           | 1.0 MB  00:00:00
(6/7): updates/7/x86_64/primary_db                                                      | 4.7 MB  00:00:00
(7/7): epel/x86_64/primary_db                                                           | 6.9 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 1:6.17.1-1.el7 will be installed
--> Processing Dependency: npm = 1:3.10.10-1.6.17.1.1.el7 for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Processing Dependency: libuv >= 1:1.9.1 for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Processing Dependency: libicudata.so.50()(64bit) for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Processing Dependency: libicui18n.so.50()(64bit) for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Processing Dependency: libicuuc.so.50()(64bit) for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Processing Dependency: libuv.so.1()(64bit) for package: 1:nodejs-6.17.1-1.el7.x86_64
--> Running transaction check
---> Package libicu.x86_64 0:50.2-4.el7_7 will be installed
---> Package libuv.x86_64 1:1.40.0-1.el7 will be installed
---> Package npm.x86_64 1:3.10.10-1.6.17.1.1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package               Arch                  Version                                 Repository           Size
===============================================================================================================
Installing:
 nodejs                x86_64                1:6.17.1-1.el7                          epel                4.7 M
Installing for dependencies:
 libicu                x86_64                50.2-4.el7_7                            base                6.9 M
 libuv                 x86_64                1:1.40.0-1.el7                          epel                152 k
 npm                   x86_64                1:3.10.10-1.6.17.1.1.el7                epel                2.5 M

Transaction Summary
===============================================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 14 M
Installed size: 51 M
Downloading packages:
(1/4): libicu-50.2-4.el7_7.x86_64.rpm                                                   | 6.9 MB  00:00:00
(2/4): libuv-1.40.0-1.el7.x86_64.rpm                                                    | 152 kB  00:00:00
(3/4): nodejs-6.17.1-1.el7.x86_64.rpm                                                   | 4.7 MB  00:00:00
(4/4): npm-3.10.10-1.6.17.1.1.el7.x86_64.rpm                                            | 2.5 MB  00:00:00
---------------------------------------------------------------------------------------------------------------
Total                                                                           42 MB/s |  14 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libicu-50.2-4.el7_7.x86_64                                                                  1/4
  Installing : 1:libuv-1.40.0-1.el7.x86_64                                                                 2/4
  Installing : 1:npm-3.10.10-1.6.17.1.1.el7.x86_64                                                         3/4
  Installing : 1:nodejs-6.17.1-1.el7.x86_64                                                                4/4
  Verifying  : 1:libuv-1.40.0-1.el7.x86_64                                                                 1/4
  Verifying  : 1:npm-3.10.10-1.6.17.1.1.el7.x86_64                                                         2/4
  Verifying  : 1:nodejs-6.17.1-1.el7.x86_64                                                                3/4
  Verifying  : libicu-50.2-4.el7_7.x86_64                                                                  4/4

Installed:
  nodejs.x86_64 1:6.17.1-1.el7

Dependency Installed:
  libicu.x86_64 0:50.2-4.el7_7      libuv.x86_64 1:1.40.0-1.el7      npm.x86_64 1:3.10.10-1.6.17.1.1.el7

Complete!
thor@host01 /$

thor@host01 /$ node -v
v6.17.1

thor@host01 /$ date
Tue Jan 12 17:15:01 UTC 2021
thor@host01 /$



Using curl we can download recursively and uses libcurl.

curl supports FTP , FTPS , HTTP , HTTPS , SCP , SFTP , TFTP , TELNET , DICT , LDAP , LDAPS , FILE , POP3 , IMAP , SMTP , RTMP and RTSP . wget supports HTTP , HTTPS and FTP .

curl offers upload and sending capabilities. wget only offers plain HTTP POST support.

If you use curl -sL https://rpm.nodesource.com/setup_13.x | sudo bash -;sudo yum install -y nodejs it will install node 13.x version.

thor@host01 /$ node -v
v13.14.0

else it will install node version 6.x.

To answer your first question: with curl, you download a script. It’s then immediately piped into bash, which executes the script. Another way to achieve that is just downloading the script to a file and running it from there.

It’s true that you need to do neither one of these steps to install nodejs, but you won’t get the right version. What this script does, is set up yum, so that when you install nodejs, you will install version 13. If you don’t do that, you will probably install the latest version. You can check which one the latest is the nodejs website.

EDIT: didn’t read that you mention the check passes, even if you don’t run the script. The reason will be that either the validation doesn’t check the version, or the default version in the CentOS repositories is version 13.