Setup: Install Node.js
Install the long-term support version of Node.js and npm, which you will use for JavaScript and React.
Novice · Operating System · Node.js · Updated
After this lesson you can
- Install Node.js and check the versions of node and npm
macOS only. Node.js runs JavaScript outside a web browser. You will need it in Sprint 3, when you build apps with React. It comes with npm, which downloads JavaScript libraries for your projects.
We install the LTS (long-term support) version: Node.js 26.
Install Node.js
brew install node
Close the Terminal window and open a new one.
Check your work
node --version
npm --version
You should see a version that starts with v26. for Node.js, and a version number for npm.
Run one line of JavaScript to see Node.js work:
node -e "console.log('Node.js is ready')"
You should see Node.js is ready.
Common problems
| What you see | What to do |
|---|---|
zsh: command not found: node |
Open a new terminal window. If it still fails, run brew doctor and follow what it says about your PATH. |
node --version shows an older version, such as v24. |
Another Node.js was installed earlier. Run which node: it should show a path inside Homebrew (/opt/homebrew or /usr/local). If it does not, a tool such as nvm sets Node.js in your settings file: run code ~/.zshrc, remove or comment out the nvm lines, save it, and open a new terminal window. |
node --version shows a newer version, such as v27. |
Homebrew's node is always the newest release. Run brew uninstall node, then brew install node@26, and follow the PATH line Homebrew prints. |