Installing Node.js
Download the Node.js from this website
Navigate to the Downloads folder from the command line:
cd ~/Downloads
Extract the downloaded node package:
tar xf node*.tar.xz
Navigate to the extracted bin file:
cd node*
cd bin
Copy the node file under/usr/local/bin/ (create the bin folder if it doesn’t exist):
cp node /usr/local/bin/
You should be able to see node version now:
node -v
eg.: v8.11.2
Installing npm
Now navigate to the npm folder:
cd ..
cd lib/node_modules/npm/scripts
And install npm:
sudo sh install.sh
Verify that you have npm installed:
npm -v
eg.: 6.0.1