I recommend using Node Version Manager:

NB: Node Version Manager (nvm) allows you to install multiple node versions and choose between them depending on which software you want to support; that is, manage multiple node versions.

Installing Node Version Manager

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

Once you have Node Version Manager installed

  1. Confirm the available remote versions by running nvm ls-remote
  2. Run in your terminal nvm install <version> for example, nvm install 18 to install version 18 of Node
  3. List installed versions with nvm list
  4. Run nvm use 18 to start using version 18 of Node
  5. Note: you can be more explicit, for example: nvm install 14.17.0
Answer from Krapp on Stack Overflow
🌐
Liquid Web
liquidweb.com › home › how to install node.js on ubuntu 22.04 via nvm
How to Install Node.js on Ubuntu 22.04 via NVM | Liquid Web
February 19, 2025 - You can install a specific version by passing the version number to the nvm install command: ... The command syntax used above will download and install Node v12.22.12.
Top answer
1 of 4
90

I recommend using Node Version Manager:

NB: Node Version Manager (nvm) allows you to install multiple node versions and choose between them depending on which software you want to support; that is, manage multiple node versions.

Installing Node Version Manager

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

Once you have Node Version Manager installed

  1. Confirm the available remote versions by running nvm ls-remote
  2. Run in your terminal nvm install <version> for example, nvm install 18 to install version 18 of Node
  3. List installed versions with nvm list
  4. Run nvm use 18 to start using version 18 of Node
  5. Note: you can be more explicit, for example: nvm install 14.17.0
2 of 4
29

Install nodejs v20 on Debian and Ubuntu based distributions

step 1 : Download and import the Nodesource GPG key

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

step 2 : Create deb repository

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

optional: here we are installing nodejs v20 but if you want to install v18 change NODE_MAJOR=18 in above command. Similarly if you want to install nodejs v16 then change NODE_MAJOR=16.

step 3 : Run Update and Install

sudo apt-get update
sudo apt-get install nodejs -y

congratulations you just installed nodejs

To uninstall nodejs

sudo apt-get purge nodejs &&\
rm -r /etc/apt/sources.list.d/nodesource.list &&\
rm -r /etc/apt/keyrings/nodesource.gpg
Discussions

node.js - installing node lts with nvm on windows - Stack Overflow
I've installed nvm on windows (from here), but running nvm install lts prints: lts.0.0 Node.js vlts.0.0 is only available in 32-bit. How do I install node lts on windows? More on stackoverflow.com
🌐 stackoverflow.com
In an Ubuntu 22 I can't install node latest version
thanks for letting us know! More on reddit.com
🌐 r/Ubuntu
8
0
March 7, 2024
node.js - How to install nvm on Mac? - Stack Overflow
After running these commands, nvm should be set up correctly. You can verify the installation by checking the nvm version: ... Sign up to request clarification or add additional context in comments. ... Thanks. It works. 2025-06-22T12:33:08.573Z+00:00 More on stackoverflow.com
🌐 stackoverflow.com
node.js - nvm install node fails to install on macOS Big Sur M1 Chip - Stack Overflow
I'm trying to install the latest version of node using nvm. I've just got the newly released SIlicon Macbook Pro with the M1 chip (not sure if that is related). I've installed xcode on the app stor... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/ubuntu › in an ubuntu 22 i can't install node latest version
r/Ubuntu on Reddit: In an Ubuntu 22 I can't install node latest version
March 7, 2024 - Warning: The version of Node.js included with Ubuntu 22.04, version 12.22.9, is an LTS, or “long-term support” release. It is technically outdated, but should be supported until the release of Ubuntu 24.04 ... install it via NVM, and not through bloated and unecessary things like snap, or whatever else Ubuntu has to offer
Top answer
1 of 4
113

To resolve this issue, ensure that nvm is properly set up in your shell configuration. Since you are using zsh, add the following lines to your .zshrc file:

brew upgrade
brew install nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh"' >> ~/.zshrc
echo '[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix nvm)/etc/bash_completion.d/nvm"' >> ~/.zshrc
source ~/.zshrc

After running these commands, nvm should be set up correctly. You can verify the installation by checking the nvm version:

$ nvm --version
2 of 4
13

Looking at the warning which you added in your question, I surmise that nvm is installed on your machine but may not have been setup properly. Nevertheless, adding full steps for you to verify which one you missed and fix the same.

1. Confirm nvm is installed

Before making changes, check if nvm exists:

# confirm nvm is installed
$ brew list | grep nvm
# if the above doesn't return anything, install nvm
$ brew install nvm

2. Ensure your system is in good shape

Sometimes Homebrew issues prevent nvm from working properly. For that run:

$ brew doctor
# If you see any warnings, follow the suggested fixes and 
# rerun brew doctor until everything looks good. 

3. Create the nvm directory (if missing)

$ mkdir -p ~/.nvm

4. Add nvm to your shell configuration

Manually add these lines to ~/.zshrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$(brew --prefix nvm)/nvm.sh" ] && . "$(brew --prefix nvm)/nvm.sh"
[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && . "$(brew --prefix nvm)/etc/bash_completion.d/nvm"

Save the file and reload the configuration:

$ source ~/.zshrc

5. Verify and Restart

Check if nvm is now working:

$ nvm -v

If you still get an error, restart your terminal and try again. Sometimes failing to do this might also lead to issues.

🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-install-nvm-on-ubuntu-22-04
How to Install NVM on Ubuntu 22.04 - GeeksforGeeks
July 23, 2025 - By following the steps outlined in this guide, you should be able to install NVM, verify the installation, install Node.js versions, and switch between them effortlessly.
Find elsewhere
🌐
HeyNode
heynode.com › tutorial › install-nodejs-locally-nvm
Install Node.js Locally with Node Version Manager (nvm) | HeyNode
If you’re installing Node.js on your production environment you should consider using your OS’s package manager, or your server tooling of choice, to install and lock the environment to a specific version of Node.js. The official documentation for how to install nvm, and some common trouble shooting tips, is in the project’s README.
🌐
GitHub
github.com › nvm-sh › nvm
GitHub - nvm-sh/nvm: Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
apk add -U curl bash ca-certificates openssl ncurses coreutils python2 make gcc g++ libgcc linux-headers grep util-linux binutils findutils curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash · Note: Alpine 3.5 can only install NodeJS versions up to v6.9.5, Alpine 3.6 can only install versions up to v6.10.3, Alpine 3.7 installs versions up to v8.9.3, Alpine 3.8 installs versions up to v8.14.0, Alpine 3.9 installs versions up to v10.19.0, Alpine 3.10 installs versions up to v10.24.1, Alpine 3.11 installs versions up to v12.22.6, Alpine 3.12 installs versions up to v12.22.12, Alpine 3.13 & 3.14 install versions up to v14.20.0, Alpine 3.15 & 3.16 install versions up to v16.16.0 (These are all versions on the main branch).
Starred by 90.3K users
Forked by 9.7K users
Languages   Shell 98.0% | Makefile 1.2%
🌐
SitePoint
sitepoint.com › blog › javascript › installing multiple versions of node.js using nvm
Installing Multiple Versions of Node.js Using nvm — SitePoint
March 3, 2025 - We introduce nvm, a handy command-line tool that allows you to install multiple versions of Node.js and switch between them with ease.
🌐
npm
docs.npmjs.com › downloading-and-installing-node-js-and-npm
Downloading and installing Node.js and npm | npm Docs
To publish and install packages to and from the public npm registry or a private npm registry, you must install Node.js and the npm command line interface using either a Node version manager or a Node installer. We strongly recommend using a Node version manager like nvm to install Node.js and npm.
🌐
DreamHost
help.dreamhost.com › hc › en-us › articles › 360029083351-Installing-a-custom-version-of-NVM-and-Node-js
Installing a custom version of NVM and Node.js – DreamHost Knowledge Base
Overview This article walks you through installing Node.js using Node Version Manager (NVM) on a VPS or Dedicated Server. DreamHost support is unable to assist with custom installations. The dir...
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › javascript › nodejs-on-windows
Set up Node.js on native Windows | Microsoft Learn
Besides choosing whether to install on Windows or WSL, there are additional choices to make when installing Node.js. We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple Node.js versions based on the needs of different projects you're working on. Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node.js, but is only available for Mac/Linux and not supported on Windows.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-node-js-on-ubuntu-22-04
How to Install Node.js on Ubuntu (Step-by-Step Guide) | DigitalOcean
May 28, 2025 - This guide provides detailed instructions for installing Node.js on an Ubuntu 22.04 server using three different methods. It starts with the basic method of using apt to install Node.js from the default repositories, suitable for most users who need a stable version. Then, it introduces the use of a NodeSource PPA to access more versions of Node.js, followed by an explanation of how to use nvm (Node Version Manager) for managing multiple Node.js versions.
🌐
Node.js
nodejs.org › en › download
Node.js — Download Node.js®
InfoWant new features sooner? Get the latest Node.js version instead and try the latest improvements! BashCopy to clipboard and their installation scripts are not maintained by the Node.js project.
🌐
4Geeks
4geeks.com › how-to › nvm-install-windows
How to install NVM on Windows
July 16, 2025 - 2) Install NVM on your Windows Computer · 3) Follow the installation wizard · 4) Find it on your command Prompt · 5) Install Node version 22 or whatever version you want · 6) Checking installed node versions · 7) Changing between different node versions: 8) VSCode PowerShell must be able to execute scripts ·
🌐
BlueVPS
bluevps.com › blog › how to install node.js on ubuntu 22.04: step-by-step guide
How to Install Node.js on Ubuntu 22.04: Step-by-Step Guide - Blog - BlueVPS
You can install Node.js on Ubuntu 22.04 using the different ways that are listed below: 1. Install Node.js on Ubuntu using Ubuntu apt repository · 2. Install Node.js on Ubuntu using NVM (Node Version Manager)