1. Run this command to setup required components before installing nodejs
sudo rpm -Uvh https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
2. Then install Nodejs
sudo yum install nodejs3. Check nodejs installed versionnode --version
sudo rpm -Uvh https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
Retrieving https://rpm.nodesource.com/pub_4.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
warning: /var/tmp/rpm-tmp.hOuTrS: Header V3 RSA/SHA1 Signature, key ID 34fa74dd: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:nodesource-release-el7-1 ################################# [100%]
[ec2-user@ip- ~]$ sudo yum install nodejs
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
epel/x86_64/metalink | 6.3 kB 00:00
nodesource | 2.5 kB 00:00
pgdg93 | 4.1 kB 00:00
rhui-REGION-client-config-server-7 | 2.9 kB 00:00
rhui-REGION-rhel-server-optional | 3.5 kB 00:00
rhui-REGION-rhel-server-releases | 3.5 kB 00:00
rhui-REGION-rhel-server-rh-common | 3.8 kB 00:00
rhui-REGION-rhel-server-supplementary | 3.4 kB 00:00
(1/3): nodesource/x86_64/primary_db | 59 kB 00:00
(2/3): rhui-REGION-rhel-server-supplementary/7Server/x86_6 | 45 kB 00:00
(3/3): rhui-REGION-rhel-server-supplementary/7Server/x86_6 | 230 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 1:6.10.1-2.el7 will be installed
--> Processing Dependency: npm = 1:3.10.10-1.6.10.1.2.el7 for package: 1:nodejs-6.10.1-2.el7.x86_64
--> Processing Dependency: libuv >= 1:1.9.1 for package: 1:nodejs-6.10.1-2.el7.x86_64
--> Processing Dependency: libuv.so.1()(64bit) for package: 1:nodejs-6.10.1-2.el7.x86_64
--> Running transaction check
---> Package libuv.x86_64 1:1.10.2-1.el7 will be installed
---> Package npm.x86_64 1:3.10.10-1.6.10.1.2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
nodejs x86_64 1:6.10.1-2.el7 epel 4.6 M
Installing for dependencies:
libuv x86_64 1:1.10.2-1.el7 epel 109 k
npm x86_64 1:3.10.10-1.6.10.1.2.el7 epel 2.5 M
Transaction Summary
================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 7.3 M
Installed size: 26 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): libuv-1.10.2-1.el7.x86_64.rpm | 109 kB 00:02
(2/3): npm-3.10.10-1.6.10.1.2.el7.x86_64.rpm | 2.5 MB 00:08
(3/3): nodejs-6.10.1-2.el7.x86_64.rpm | 4.6 MB 00:16
--------------------------------------------------------------------------------
Total 447 kB/s | 7.3 MB 00:16
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : 1:libuv-1.10.2-1.el7.x86_64 1/3
Installing : 1:npm-3.10.10-1.6.10.1.2.el7.x86_64 2/3
Installing : 1:nodejs-6.10.1-2.el7.x86_64 3/3
Verifying : 1:libuv-1.10.2-1.el7.x86_64 1/3
Verifying : 1:nodejs-6.10.1-2.el7.x86_64 2/3
Verifying : 1:npm-3.10.10-1.6.10.1.2.el7.x86_64 3/3
Installed:
nodejs.x86_64 1:6.10.1-2.el7
Dependency Installed:
libuv.x86_64 1:1.10.2-1.el7 npm.x86_64 1:3.10.10-1.6.10.1.2.el7
Complete!
[ec2-user@ip-172-31-4-45 ~]$ node --version
v6.10.1
curl -sL https://rpm.nodesource.com/setup | bash -
================================================================================
================================================================================
SCRIPT DEPRECATION WARNING
This script, located at https://rpm.nodesource.com/setup, used to
install Node.js v0.10, is being deprecated and will eventually be made
inactive.
You should use the script that corresponds to the version of Node.js you
wish to install. e.g.
* https://rpm.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)
* https://rpm.nodesource.com/setup_6.x — Node.js v6 Current
Please see https://github.com/nodejs/LTS/ for details about which version
may be appropriate for you.
The NodeSource Node.js Linux distributions GitHub repository contains
information about which versions of Node.js and which Linux distributions
are supported and how to use the install scripts.
https://github.com/nodesource/distributions
================================================================================
================================================================================
Continuing in 10 seconds (press Ctrl-C to abort) ...
## Installing the NodeSource Node.js v0.10 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 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.YqE52h2nSA' 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.YqE52h2nSA'
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
Error executing command, exiting
[ec2-user@ip-172-31-4-45 ~]$ sudo curl -sL https://rpm.nodesource.com/setup | bash -
================================================================================
================================================================================
SCRIPT DEPRECATION WARNING
This script, located at https://rpm.nodesource.com/setup, used to
install Node.js v0.10, is being deprecated and will eventually be made
inactive.
You should use the script that corresponds to the version of Node.js you
wish to install. e.g.
* https://rpm.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)
* https://rpm.nodesource.com/setup_6.x — Node.js v6 Current
Please see https://github.com/nodejs/LTS/ for details about which version
may be appropriate for you.
The NodeSource Node.js Linux distributions GitHub repository contains
information about which versions of Node.js and which Linux distributions
are supported and how to use the install scripts.
https://github.com/nodesource/distributions
================================================================================
================================================================================
Continuing in 10 seconds (press Ctrl-C to abort) ...
## Installing the NodeSource Node.js v0.10 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 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.lEXvKWHzpI' 'https://rpm.nodesource.com/pub_0.10/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.lEXvKWHzpI'
error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Permission denied)
Error executing command, exiting