To Install NodeJS, just visit the Node’s official website and download the latest stable version of NodeJS for your Operating System (OS).
Node’s official website provides installers for the Windows and Mac OS. You can download the installer, run it and follow the on-screen instructions to setup NodeJS for your own Operating System. For Linux you need to download the Linux Binary(x86/x64), extract it and add the NodeJS executable to your system’s path variable. Follow the steps below to install NodeJS on linux platform-
Download the latest version of NodeJS Linux Binary(x86/x64) from the official website of NodeJS.
wget https://nodejs.org/dist/v14.2.0/node-v14.2.0-sunos-x64.tar.xz
Now, extract the tar file.
tar xzvf node-v14.2.0-sunos-x64.tar.xz
Now, create a directory to store NodeJS binary, and move NodeJS binary to the newly created directory.
sudo mkdir -p /usr/local/nodejs
sudo mv node-v14.2.0-sunos-x64.tar.xz/* /usr/local/nodejs
Now, add the NodeJS executable to your system’s path variable.
export PATH="$PATH:/usr/local/nodejs/bin"