Factsheet
upgrade - Upgrading Node.js to the latest version - Stack Overflow
node.js - How to install certain node version from command line - Stack Overflow
Hi! How can I install Node.js on my windows?
[How-To] Install Node.js on Windows the Recommended Way
Videos
Per the Node.js website:
# Using Debian/Ubuntu
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
Then, you will have the latest version of Node.js.
If you're not a fan of curl <url> | bash -, or are using an unsupported distribution, you can try a manual installation.
Node is one of the easier projects to build. Just change the version as that continues to change.
Browse to http://nodejs.org/dist/latest/ to find out the latest package version.
cd /usr/local/src
wget http://nodejs.org/dist/latest/node-v7.2.1.tar.gz
tar -xvzf node-v7.2.1.tar.gz
cd node-v7.2.1
./configure
make
sudo make install
which node
You should see /usr/local/bin/node.
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!
You should use nvm to install and manage node versions and not npm
NPM is the package manager for node and not a version manager.
To install a particular version of node using nvm, just do
nvm install v0.10.32
NPM should be used to install packages/modules. So say you need to use request module for a particular project You can do
npm install request
Both these support tons of options which could be found over the documentations
I recommend you use nvm: Nodev Version Manager
It would be as easy as
nvm install 6.9.4
It's a really good tool to manager all of your node versions.