How to Install Node.js using NVM on MacOS and Ubuntu
Tutorial of how Node.js can be installed on MacOS and Ubuntu to start your node projects.

Table of Contents
Node.js can be installed in different ways, in this article we are going to leave NVM and see how it can be installed on our Mac or Ubuntu machines. M1 or M2 are also supported with these.
Hetzner Cloud: Unleash Your Projects with Free Credits
Power up your cloud hosting with €20 free credits! Enjoy reliable, scalable servers to bring your ideas to life without breaking the bank.
*Affiliate link
1. NVM Installation
1.1 Mac NVM Installation
Install Homebrew
Homebrew is the package manager that will be used to install the node. If you are already using it you should skip this step.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install NVM with Homebrew on Mac
To do this you just need to follow the below steps:
brew install nvm
Then create a directory in the user home
mkdir ~/.nvm
When using the zsh shell, add the following config inside ~/.zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
To activate the changes you either login logout or do:
source ~/.zshrc
At the end you can check to see the nvm version with the below command:
nvm --version
Youtube Video With Details
1.2 Ubuntu NVM Installation
Homebrew can be used also on Ubuntu but it’s recommended to use the default repo. In this part, we are going to see how we can install NVM on Ubuntu to use it for the last part Node.JS install.
Install NVM:
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
The script will do the rest and activate everything needed on the user profile. You just need to source it to have the changes, you can login/logout or do:
Windsurf IDE: Code Smarter with 500 Free Credits
Supercharge your development workflow with Windsurf IDE. Get 500 free credits to explore cutting-edge tools and streamline your coding projects.
*Affiliate link
source ~/.bashrc
At the end you can check to see the nvm version with the below command:
nvm --version
2. Install Node.js with NVM
This part can be done on both Mac and Ubuntu as it uses the NVM to install node.
There are multiple versions of node out there, in function of what your application is supporting you should install the right version, you can also install multiple versions and tell what to use. In this case, we are going to go with LTS one which is 16.
To install the current LTS Node.js version, execute:
nvm install --lts
See the version used:
node --version
You can install multiple nodejs versions and choose what to use.
Install the second version:
nvm install 18
Use a specific version:
EmailOctopus: Reach More with 10,000 Free Emails
Grow your audience effortlessly with EmailOctopus. Send up to 10,000 emails per month for free and connect with your subscribers like never before.
*Affiliate link
nvm use 16
Related Posts


How to Update All Node.js Dependencies to Their Latest Version
Learn how to update all your Node.js dependencies to their latest version using the npm-check-updates tool. Avoid breaking changes, dependency conflicts, and security issues by following this simple guide.

Easypanel.io: A Modern Hosting Panel for Applications and Databases
Check out Easypanel.io, a web-based server control panel that helps you deploy and manage applications, databases, and SSL certificates with a simple and powerful interface. It supports various languages, frameworks, templates, and integrations. It also offers zero-downtime deployments and web consoles.