In this article, we’ll cover all methods of how to upgrade NodeJs to Latest version in Linux Os, Ubuntu Os, Windows 7, 8, 10, and Mac Osx using NPM (Node Package Manager) and NVM (Node Version Manager). And finally, we ‘re going to explore the Best way to upgrade Node. JS
Node.js helps in the development of fast and extensible applications as a runtime environment. And not only are the apps fast-so are the updates. They come on once every few weeks, improving protection, stability and adding some new features.
And if you want an update, in fact, there is a very easy way to do that. Here are some of the ways to update Node on different operating systems.
Also Read: File Upload in Node js using Multer
How to upgrade nodejs to latest version using pre-installed Node Package Manager (npm)
You can also update your node.js using the Node Package Manager (npm). Node comes with a package manager that has already been pre-installed-but before you update Node.js, you need to make sure that npm is the latest version as well.
- First, you may want to find out the Node Package Manager version you have, by running an
npm -v
command. - Once done, use
npm install npm@latest -g
command to install the latest Node Package Manager version available. - Finally, use
npm -v
command to confirm whether your new Node Package Manager was successfully installed.
To update node.js using the Node Package Manager, use the Node Package Manager’s n module.
1. First, clear the npm cache:
2 3 4 5 6 7 8 |
For Window: npm cache clean -f For Linux, Ubuntu or MAC sudo npm cache clean -f |
2. Install n, Node’s version manager:
2 3 4 5 6 7 8 |
For Window: npm install -g n For Linux, Ubuntu or MAC sudo npm install -g n |
3. Install the latest stable version:
2 3 4 5 6 7 8 |
For Window: n stable For Linux, Ubuntu or MAC sudo n stable |
How to upgrade nodejs to latest version using Node Version Manager (nvm):
Node Version Manager (NVM) is a popular way to upgrade your node.js.
1. update the package repository
2 3 4 |
sudo apt update |
2. Download the required dependencies
2 3 4 |
sudo apt install build-essential checkinstall libssl-dev |
3. Install NVM using the curl command:
2 3 4 |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.1/install.sh | bash |
You can use Wget as well. Here’s the script:
2 3 4 |
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash |
4. Close and reopen the terminal.
5. Now, verify if you have successfully installed NVM:
2 3 4 |
nvm --version |
6. Before upgrading Node.js, check which version you have running on the system:
2 3 4 |
nvm ls |
7. Now you can check for newly available releases with:
2 3 4 |
nvm ls-remote |
8. Download and install a new version of node.js.
2 3 4 |
nvm install #.#.# |
OR
2 3 4 |
nvm install version.number |
Wrapping Words!
Well, I hope you found Complete Steps How to upgrade nodejs to latest version tutorial helpful for your project. Keep learning!. If you face any problem – I am here to solve your problems.
Are you want to get implementation help, or modify or extend the functionality of this script? Submit a paid service request
Pradeep Maurya is the Professional Web Developer & Designer and the Founder of “Tutorials website”. He lives in Delhi and loves to be a self-dependent person. As an owner, he is trying his best to improve this platform day by day. His passion, dedication and quick decision making ability to stand apart from others. He’s an avid blogger and writes on the publications like Dzone, e27.co