2026 Update: Use FNM
fnm is a fully rust based node.js version manager and 10x faster than nvm. Works on Windows, Mac and Linux unlike nvm
Check which version of fnm is installed
fnm --version
- install a specific version of node
fnm install 22.12.10
- use a specific version of node
fnm use 22.12.10
- Check out all the fnm commands here
Older answer with nvm
To upgrade Node you may first want to see which version of Node.js you are currently using:
node --version
Find out which versions of Node.js you may have installed and which one of those you're currently using:
nvm ls
List all versions of Node.js available for installation:
nvm ls-remote
Apparently for Windows the command would be rather like this:
nvm ls available
Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version:
nvm install 8.1.0
You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:
nvm use 4.2
That should be all.
In 2013 I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac, for more recent instructions see above.
Update from 2017: Please mind, Mr. Walsh himself recommended to update Node.js just using nvm instead.
Clear NPM's cache:
sudo npm cache clean -fInstall a little helper called 'n'
sudo npm install -g nInstall latest stable Node.js version
sudo n stable
Alternatively pick a specific version and install like this:
sudo n 0.8.20
For production environments you might want to pay attention to version numbering and be picky about odd/even numbers.
Credits
- General procedure: D.Walsh
- Stable/unstable versions: P.Teixeira
2026 Update: Use FNM
fnm is a fully rust based node.js version manager and 10x faster than nvm. Works on Windows, Mac and Linux unlike nvm
Check which version of fnm is installed
fnm --version
- install a specific version of node
fnm install 22.12.10
- use a specific version of node
fnm use 22.12.10
- Check out all the fnm commands here
Older answer with nvm
To upgrade Node you may first want to see which version of Node.js you are currently using:
node --version
Find out which versions of Node.js you may have installed and which one of those you're currently using:
nvm ls
List all versions of Node.js available for installation:
nvm ls-remote
Apparently for Windows the command would be rather like this:
nvm ls available
Assuming you would pick Node.js v8.1.0 for installation you'd type the following to install that version:
nvm install 8.1.0
You are then free to choose between installed versions of Node.js. So if you would need to use an older version like v4.2.0 you would set it as the active version like this:
nvm use 4.2
That should be all.
In 2013 I used the following instructions to upgrade from Node.js version 0.10.6 to 0.10.21 on a Mac, for more recent instructions see above.
Update from 2017: Please mind, Mr. Walsh himself recommended to update Node.js just using nvm instead.
Clear NPM's cache:
sudo npm cache clean -fInstall a little helper called 'n'
sudo npm install -g nInstall latest stable Node.js version
sudo n stable
Alternatively pick a specific version and install like this:
sudo n 0.8.20
For production environments you might want to pay attention to version numbering and be picky about odd/even numbers.
Credits
- General procedure: D.Walsh
- Stable/unstable versions: P.Teixeira
Use Node Version Manager (NVM)
It's a Bash script that lets you download and manage different versions of node. Full source code is here.
There is a separate project for nvm for Windows: github.com/coreybutler/nvm-windows
Below are the full steps to use NVM for multiple version of node on windows
- download nvm-setup.zip extract and install it.
- execute command
nvm list availablefrom cmd or gitbash or powershell, this will list all available version of node - use command
nvm install versione.g.nvm install 12.14.0to install on the machine - last once installed use
nvm use versionto use newer version e.g.nvm use 12.14.0
Use n module from npm in order to upgrade node
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
To upgrade to latest version (and not current stable) version, you can use
sudo n latest
Fix PATH:
sudo apt-get install --reinstall nodejs-legacy # fix /usr/bin/nodeTo undo:
sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n
You may need to restart your terminal to see the updated node version.
Found in David Walsh blog
NodeSource provides binary distributions of Node.js; complete installation instructions can be found here. The instructions have been copied below for your reference. Instructions are the same for updating to the latest version.
Run once:
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
Run whenever you want to change the major version of Node.js:
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
sudo apt-get update
sudo apt-get install nodejs -y
Prior to August 2023: Previously versions of this answer involved the use of a series of setup_XX.x scripts that you'd run to install/update Node.js:
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
But as @eis pointed out, these scripts are no longer supported. To see the previous answers, please look at the edit history for this answer.
Videos
Do you need any tool to upgrade Node js to latest version?
What is the current Node js version?
Our application is built upon Vue, Nunjucks, Express and around 80 other dependencies. Around 30 packages have been deprecated. It’s a live application with around 15 million daily viewers. Currently the application is built upon Node 14.x version and they haven’t upgrade the Node for a few years.
Now they have delegated the task to me to upgrade the application to Node 20.x.
Tbh, I’m a bit overwhelmed since the tech debt is massive and currently I’m the only one working on it, so I need your help to figure our the correct direction from which to approach this task.
So, far I could figure two possible approaches:
To install node 20.x in the local using nvm and the npm install, then run npm build and troubleshoot all the build errors one by one.
To start from an empty folder with node 20.x and start migrating few files at a time by removing most features and then adding stuff bit by bit to make the application work at the simplest level and then build upon it.
Please suggest the correct approach for handling this task.
Thanks!
I usually use nvm.
With this tool you can utilize any version of node, side by side on the same machine.
You can install it with curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
Then download your desired node version nvm install 14 .
Nvm has many other options for managing your node runtimes so check the man page.
You can do this using installation instructions from official Node.js website - Installing Node.js via package manager. Namely for Ubuntu you'll be directed to nodesource/distributions at GitHub. Find the following paragraph - Installation instructions. It stated for example:
Node.js v14.x:
# Using Ubuntu
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Ubuntu Linux/Mac
The module n makes version-management easy:
sudo npm install n -g
For the latest stable version:
n stable
For the latest version:
n latest
Debian 10
Upgrade older versions of node and npm on Debian 10 as follows:
sudo su -c 'curl -sL https://deb.nodesource.com/setup_18.x | bash -'
sudo apt-get install nodejs -y
sudo apt update
sudo apt upgrade
sudo npm install -g [email protected]
node --version
npm --version
Note: Replace setup_18 with the latest long-term support release.
Windows
Just reinstall node from the .msi in Windows from the node website.
All Platforms (Mac, Linux & Windows) 2024
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
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.
Mac
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.3/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 Specific 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 v22.16.0
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 v22.16.0
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
sudowith 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 it 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!
To update nodejs to 14.x run the following commands:
sudo apt update
curl -sL https://deb.nodesource.com/setup_14.x | sudo bash -
sudo apt install -y nodejs
node -v
After running the final command you should see:
v14.15.0
Update for 2024
Since this question was posted, version 20 became the newest LTS version. So Ahmed Boutaraa's answer was correct for the version 14 part of the question, but people stumbling on this question may be seeking the most recent LTS. If you follow those instructions, you will be stuck in version 14.
Luckily, NodeSource also provides an installation script that installs the current LTS rather than a specific version. That should make this answer a bit more future-proof. You can also get the same info straight from the source.
As an aside, there is a script called nvm that is great for managing your node version. It makes it easy to install multiple versions, like if you work with multiple projects with different version requirements or if you want to experiment with the latest version and easily switch back to LTS for regular work. You can find installation instructions on their repository.
How to install the latest LTS version
This set of instructions will install whatever version is the latest LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.
# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# OR as root
curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
How to install the latest non-LTS version
This set of instructions will install whatever version is the latest non-LTS version. When a new version is released, you may have to run these instructions again to pull the new install script for the new version.
# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
# OR as root
curl -fsSL https://deb.nodesource.com/setup_current.x | bash -
apt-get install -y nodejs
How to lock into v21 (latest, for now)
# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash -
sudo apt-get install -y nodejs
# OR as root
curl -fsSL https://deb.nodesource.com/setup_21.x | bash -
apt-get install -y nodejs
How to lock into v20 (current LST)
# As a user with sudo
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# OR as root
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y nodejs