- Simply go to the official website of Node.js or click here to download th latest version of node.js.
- After you downloaded the package, extract it using the command :
tar -xf name_of_package
- Rename the folder just made after extraction of the package to nodejs. Command is this :
mv name_of_package nodejs
- Copy the folder ‘nodejs‘ inside the ‘bin‘ folder in root directory using the command:
sudo cp -r nodejs /bin
- At this point, you need to add the nodejs binaries in the PATH variable so that they can be executed from anywhere.
There are two ways to do this. I am using the less popular way to keep things easy. What you have to do is that copy the files inside nodejs/bin
Use this command : sudo cp /bin/nodejs/bin/*
/usr/local/bin/
- Okay all done. Check the version of Node.js and NPM using the following commands :
- If you face any error while checking the version of npm, one like this “Error: Cannot find module ‘../lib/utils/unsupported.js’ “ do the following :
- Remember the ‘nodejs’ folder in the ‘Downloads’?
- Go to Downloads folder, and give the following series of commands :
- Delete the ‘npm’ in
usr/local/bin
Use this command: sudo rm usr/local/bin/npm
cd ~/Downloads
[Go to the Downloads Folder]
cd nodejs/bin
[Go inside the binaries folder of node.js]
- Execute npm from inside the node binaries file to install latest version of NPM globally use the following command:
sudo ./npm install npm@latest -g
- Done !
- Now finally you can use the latest NPM v5.0.1 and Node.js v8/9
- Suggestions/corrections are welcome
- Thanks ! Happy coding