How to Setup Node on Mac Without Homebrew

This post shows you how to setup Node.js on a Mac without using Homebrew.

This includes installing the following:

  • A specific version of Node.js. In this case, the latest LTS (Long Term Support) version.
  • npm for package management
  • Yarn for dependency management

Download and Install nvm

nvm (Node Version Manager) is a version manager for Node.js, designed to manage multiple versions of Node.js on a single machine.

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

Verify the following are in ~/.bash_profile or ~/.zshrc:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

Verify install:

nvm --version

Install Node

To see available versions:

nvm ls-remote

Install the latest LTS (Long Term Support) version:

nvm install --lts

As of this writing, the latest LTS version is 22.12.0. You can verify the version of Node.js installed by running:

node --version

Upgrade npm

npm will be installed with Node.js. To check the version of npm installed, run:

npm --version

To upgrade npm to the latest version, run:

npm install -g npm@latest

Install Yarn

Yarn is a package manager that doubles down as project manager. It is an alternative to npm and is known for its speed.

npm install -g yarn