add

Install Node.js

Node.js on CentOs 7

node.js

In order to install Node.js on CentOS 7 , execute the following commands as root in the same order they are mentioned.

1. Go to the official site : https://nodejs.org/dist/ and goto the latest version directory.

At the time of installation, Node version 12.16.1 is the latest.

https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.gz

2) Open termional and download the latest Node.js(node-v12.16.1-linux-x64.tar.gz) executable to /tmp

# cd /tmp

# wget http://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.gz

3) Extarct the conents of the archiove file with below command.

# tar xvfz node-v8.11.2-linux-x64.tar.gz

4) create a directory for Node.js compiled and executable files.

# mkdir -p /usr/local/nodejs

5) add this path to the System path so that your shell can find/lookup the executable in this directory.

# cat /etc/profile.d/setEnv.sh
export M2_HOME=/opt/maven
export JAVA_HOME=$(readlink -f /usr/bin/java | sed “s:/bin/java::”)
export NODE_HOME=/usr/local/nodejs
export PATH=${M2_HOME}/bin:${JAVA_HOME}/bin:${NODE_HOME}/bin:${PATH}

#source /etc/profile.d/setEnv.sh

6) verify the installation by checking the version of both Node and Npm executables.

# node -v && npm -v
v12.16.1
6.13.4

Written by Ramesh Metta