Install Node.js on your Mac
You're following a tutorial, you hit a step that says npm install something,
and the terminal stops you: command not found: node or
npm: command not found. You haven't broken anything. You're
just missing Node.js. You install it once and it stays.
Node.js is what lets JavaScript run outside the browser: on your own
machine, in the terminal. Node comes with npm, the manager
you use to install packages and tools written in JavaScript (including a
pile of AI tools). Put plainly: without Node, half the dev internet won't
start on your Mac.
If you don't have Homebrew yet, install it first. It's a single line and it's the base for everything else. Here it is step by step: install Homebrew.
Install it
With Homebrew already set up, Node is one line. Paste it into the Terminal and hit Enter:
brew install node
It takes a couple of minutes. This installs the latest stable version of
Node and npm along with it, so you don't have to install them
separately.
Check it works
Run these two lines. If each one gives you back a version number, you're done:
node --version
v22.11.0
npm --version
10.9.0 The exact numbers don't matter as long as they show up. That pair of versions is all the confirmation you need.
If it still says command not found
Two common causes, both quick:
- Stale terminal. The install finished, but your terminal is still on the old PATH. Close it, open a new one, and try again.
- Homebrew isn't on the PATH. On an Apple Silicon Mac (M1 through M4), Homebrew needs two extra lines so the terminal can find it. They're in the Homebrew tutorial, in the section about the step almost everyone skips.
Ready for what's next
With Node and npm working, you can now install tools written in JavaScript with a single line. One of them is Claude Code, the AI agent that lives in your terminal and writes code with you: install Claude Code.
I build websites, automations, and AI tools, and write up what I learn along the way.
More tutorials ↗