Node install code

Mar 9, 2010 0 comments

 First, you need to add the NodeSource yum repository to your system. This can be done by using the following command as user root:

$ curl -sL | bash -

This command will first use the curl tool to download the “setup_12.x” script and then execute this script using bash.

This is the output from the script:

## Installing the NodeSource Node.js 12.x repo...

## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null ''

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.kNjfOcFMcS' ''

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.kNjfOcFMcS'

## Cleaning up...

+ rm -f '/tmp/tmp.kNjfOcFMcS'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Your system appears to already have Node.js installed from an alternative source.
Run `sudo yum remove -y nodejs npm` to remove these first.

## Run `sudo yum install -y nodejs` to install Node.js 12.x and npm.
## You may also need development tools to build native addons:
sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
curl -sL | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

Let’s check if the new yum repository has been added correctly:

$ ls -la /etc/yum.repos.d/|grep nodesource
-rw-r--r--. 1 root root 474 Apr 23 2019 nodesource-el7.repo

Based on the output from the “setup_12.x” script, we first need to remove the existing version of Node.js:

$ sudo yum remove -y nodejs npm
  nodejs.x86_64 1:6.17.1-1.el7                                   npm.x86_64 1:3.10.10-


Now let’s install the new version of Node.js:

$ sudo yum list available nodejs

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
nodejs.x86_64 2:12.14.1-1nodesource nodesource

$ sudo yum install nodejs

Total download size: 22 M
Installed size: 65 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-12.14.1-1nodesource.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 34fa74dd: NOKEY
Public key for nodejs-12.14.1-1nodesource.x86_64.rpm is not installed
nodejs-12.14.1-1nodesource.x86_64.rpm                                                                           |  22 MB  00:00:02
Retrieving key from file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <>"
 Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd
 Package    : nodesource-release-el7-1.noarch (installed)
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:nodejs-12.14.1-1nodesource.x86_64                                                                                 1/1
  Verifying  : 2:nodejs-12.14.1-1nodesource.x86_64                                                                                 1/1

  nodejs.x86_64 2:12.14.1-1nodesource


Let’s check the versions again:

$ node --version
$ npm --version

All done!



Related Posts


{{posts[0].date}} {{posts[0].commentsNum}} {{messages_comments}}


{{posts[1].date}} {{posts[1].commentsNum}} {{messages_comments}}


{{posts[2].date}} {{posts[2].commentsNum}} {{messages_comments}}


{{posts[3].date}} {{posts[3].commentsNum}} {{messages_comments}}