Upgrading Node.js to latest version – Dev

The best answers to the question “Upgrading Node.js to latest version” in the category Dev.


So, I have Node.js installed and now when I tried to install Mongoosejs I got an error telling me that I don’t have the needed version of Node.js (I have v0.4.11 and v0.4.12 is needed).

How can I upgrade to this version? I suppose I just could install it again with the latest version, but I don’t want to do it before I’m sure that my project folders in the folder “node” won’t be deleted.


All Platforms (Mac, Linux & Windows) 2021

If you just need to upgrade your old version of Node.js to the latest one and don’t need multiple versions, simply over-write your existing executable with the new one.

Download the Latest Node.js from nodejs.org/en/download

enter image description here

This Just Works! TM on all platforms and is the easiest/fastest method.
When you run node -v in your terminal you will see the the latest version.


If you originally installed Node.js using brew then run:

brew upgrade node

Managing Multiple Versions of Node.js:

If you need to run multiple versions of Node.js on your machine e.g. if you have an older project that targets a specific version on AWS Lambda, then NVM (Node Version Manger) is your friend!

Step 1 – Get NVM

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash

If you’re curious about the installation command read the source code
… its been reviewed by several node.js security experts

Step 2 – Install the version of node.js you need

Once you’ve got NVM you can install a specific version of Node.js using the nvm command:

nvm install v14.17.6

Note: you may need to close & re-open your terminal window for nvm command to be available.

You should expect to see something like this in your terminal:

Now using node v14.17.6

You now have the latest Node.js on your machine.
And if you need to temporarily switch to a different/previous version, you can do it with a simple nvm command.

Note: avoid using sudo with Node/NPM as it violates the security principal of least privilege

NVM is considered “better” than N for managing multiple Node.js versions because the verbose commands mean is much easier to keep track of what you are doing in your Terminal/SSH Log. It is used by the team at NPM the creators/custodians of the Node.js World!


Ubuntu Linux/Mac:

The module n makes version-management easy:

npm install n -g

For the latest stable version:

n stable

For the latest version:

n latest


just reinstall node from the .msi in Windows from the node website.


On Windows download latest “Windows Installer (.msi)” from https://nodejs.org/download/release/latest/
and install same directory , thats all…

After complete the installation above, the NodeJS and NPM will be upgraded to the latest one and then you can cleanup the package as normal as:

npm cache clean
npm update -g


You can always check the version with following command:

C:\node -v

C:\npm -version


via npm:

npm cache clean -f
npm install -g n
n stable

and also you can specify a desired version:

n 0.8.21