Lately, I am starting to work on the Vuejs project. I installed NodeJS and NPM before but now I want to update them to the latest version. Today I would like to share with you.
Update NPM to the latest version
First, open your terminal then run the command line below.
Check NPM version
My result of the command is 6.4.1
Then runs the command below for update the NPM to the latest version
npm install npm@latest -g
Check NPM version again
My result of the command is 6.13.0
Update NodeJS to the latest version
For Windows, it is very simple to update the NodeJS. Simply go to the NodeJS website and download the .msi file and reinstall the NodeJS on your computer. I use the LTS version.
For Linux and Mac, just uses the command below.
Check NodeJS version
sudo node -v
My result of this command is v10.15.1
Install n Module
sudo npm install -g n
If you want to check what n module does, just visit this link.
Update to the latest version
sudo n latest
After updating, I check my NodeJS version, my result of this command is v12.13.0
Update to the latest stable version
sudo n stable
That’s it. When I update NPM it takes time. So you have an old NPM version just like me, you can expect a bit more time to update the NPM to the latest version.