✨ Why Node.js for AI?
- → Claude Code — Anthropic's CLI tool runs on Node.js
- → OpenClaw — AI orchestrator framework requires Node
- → Modern tooling — npm packages for AI development
- → Cross-platform — Works on Mac, Windows, Linux
What is Node.js?
Node.js is a JavaScript runtime that lets you run JavaScript code outside of a browser. Many modern AI tools (including Claude Code and OpenClaw) are built with Node.js because it's fast, cross-platform, and has a huge ecosystem of packages.
💡 Do you need this? If you're using Claude Code, OpenClaw, or any npm-based AI tools, yes! Python developers also benefit from Node.js for tooling and utilities.
1 Install Node.js via Homebrew (Recommended for Mac)
If you have Homebrew installed (see Homebrew Setup Guide), this is the easiest method:
brew install node@20
This installs Node.js version 20 (LTS - Long Term Support), which is stable and recommended for production use.
✅ Why LTS? LTS versions are tested, stable, and receive security updates for 3 years.
2 Alternative: Direct Download
If you prefer not to use Homebrew, download directly from the official site:
- Go to nodejs.org
- Click the green "LTS" download button
- Run the installer (.pkg for Mac, .msi for Windows)
- Follow the installation wizard
3 Verify Installation
Check that Node.js and npm (Node package manager) are installed:
node --version
npm --version
You should see output like:
v20.11.010.2.4
Optional: Install nvm (Node Version Manager)
nvm lets you install and switch between multiple Node.js versions. Useful if you work on projects that require different Node versions.
brew install nvm
After installing, follow the setup instructions shown in your terminal to configure your shell.
⚠️ Note: For most users, a single LTS version is sufficient. Only install nvm if you need multiple Node versions.
Essential npm Commands
| Command | Description |
|---|---|
| npm install -g <package> | Install package globally |
| npm install <package> | Install package locally |
| npm list -g --depth=0 | List globally installed packages |
| npm update -g <package> | Update a global package |
| npm --version | Check npm version |
Troubleshooting
"command not found: node"
Node.js isn't installed or isn't in your PATH. Run brew install node@20 or download from nodejs.org.
Permission denied when installing packages
Don't use sudo! Fix npm permissions by running:
mkdir ~/.npm-global && npm config set prefix '~/.npm-global'
Old Node.js version
Update with Homebrew: brew upgrade node@20
Official Resources
🚀 What's Next?
Now that Node.js is installed, you can install AI tools that depend on it: