What you're installing and why

Node.js is a tool that lets you run JavaScript outside of a web browser — on your computer itself, or on a server. If you write JavaScript and want to test it locally, build tools that process your code, or run a web server, you need Node.js installed first.

This guide walks you through two ways to install it on macOS: using the official installer (simpler, fewer steps) or using Homebrew (easier to update later). Both end with the same result — Node.js working on your machine.

Key Takeaways

  • The official Node.js installer from nodejs.org is the fastest way to get your free guide if you have never installed development tools before.
  • Homebrew is a package manager for Mac that makes updating Node.js later much simpler, but requires a few extra setup steps the first time.
  • After installation, you verify it worked by opening Terminal and typing node --version to see which version you have.
  • Node.js includes npm (Node Package Manager), which you will use to download code libraries that other people have written.

Installing Node.js using the official installer

This is the most straightforward method. Visit nodejs.org, download the installer for macOS, and run it like any other Mac application.

Step 1: Open your web browser and go to nodejs.org. You will see two large download buttons — one says "LTS" (Long Term Support) and one says "Current". Choose LTS unless you have a specific reason to use the newest version. LTS receives security updates for longer and is more stable for learning.

Step 2: The site detects your Mac automatically. If it shows "macOS Installer" with an .pkg file, click that button. If it asks whether you have an Intel or Apple Silicon Mac, choose the correct one. (Apple Silicon is the newer chip in Macs from late 2020 onward; if you are unsure, click the Apple menu, select "About This Mac", and look for "Chip". If it says "Apple M1", "M2", or "M3", you have Apple Silicon.)

Step 3: The installer downloads as a .pkg file. Open your Downloads folder and double-click it. A window appears asking you to agree to the license and choose where to install Node.js. The default location (your Applications folder) is correct. Click Continue, then Install.

Step 4: The installer may ask for your Mac password. Type it and click Install Software. Wait for the progress bar to finish.

Step 5: When installation completes, you will see a message saying "The installation was successful". Click Close. Node.js is now installed.

Installing Node.js using Homebrew

Homebrew is a package manager — a tool that downloads and installs software from the command line. If you plan to install many development tools over time, Homebrew makes updates much simpler. However, it requires installing Homebrew first, which takes an extra step.

Step 1: Open Terminal. (Press Command + Space, type "Terminal", and press Enter.)

Step 2: Paste this command and press Enter:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

This downloads and runs the Homebrew installer. It may ask for your Mac password. Type it and press Enter. Wait for the installation to finish — it takes a few minutes.

Step 3: After Homebrew finishes, install Node.js by typing this command and pressing Enter:

brew install node

Homebrew downloads Node.js and installs it automatically. This also takes a few minutes.

Step 4: When the command finishes, Node.js is installed. You can now close Terminal or move to the next section to verify the installation.

Verifying Node.js is installed and working

After installation, you should check that Node.js is actually working. This catches any problems before you try to use it.

Step 1: Open Terminal. (Press Command + Space, type "Terminal", and press Enter.)

Step 2: Type this command and press Enter:

node --version

Terminal prints a version number like "v18.17.0" or "v20.9.0". If you see a version number, Node.js is installed correctly. If you see "command not found", the installation did not work — restart your Mac and try again.

Step 3: Check that npm (Node Package Manager) is also installed by typing:

npm --version

You should see a version number like "9.6.7". npm comes with Node.js automatically, so if Node.js installed correctly, npm will too.

Understanding what you now have

node is the program that runs JavaScript files. When you write a .js file and want to test it, you type node filename.js in Terminal and it runs.

npm is the package manager. It downloads code libraries (called packages) that other developers have written and shared. When you need a tool or library, you use npm to download it into your project folder. Most JavaScript projects have a file called package.json that lists all the packages they need — npm reads that file and downloads them all at once.

Both tools live in Terminal. You do not open them like regular applications — you type commands to use them.

Updating Node.js later

Node.js releases updates regularly. If you used the official installer, you download and run the new installer when an update comes out. If you used Homebrew, updating is one command:

brew upgrade node

This is why many developers prefer Homebrew — updates take seconds instead of downloading and running an installer by hand.

Frequently Asked Questions

Do I need Node.js to write JavaScript for websites?

No. JavaScript that runs in a web browser (the kind you write in HTML files) does not need Node.js. You only need Node.js if you want to run JavaScript on your computer itself, test code locally before putting it on a website, or use build tools that process your code.

Which installation method should I choose?

If you have never installed development tools before, use the official installer — it is simpler and faster. If you plan to install other development tools later (like Python or Ruby), install Homebrew now and use it for everything. Homebrew takes longer to set up once, but saves time later.

What does "LTS" mean and should I choose it?

LTS stands for Long Term Support. LTS versions receive security updates for years, while Current versions only get updates for a few months. Choose LTS unless you need a specific new feature that only exists in Current. LTS is more stable for learning and for production code.

Can I have two versions of Node.js installed at the same time?

Yes, but it requires a tool called nvm (Node Version Manager). Most beginners do not need this. Once you are comfortable with Node.js and need to test code on different versions, look up "nvm for Mac" to learn how to install it.

What if the installation fails or Node.js does not work after I install it?

Restart your Mac first — sometimes Terminal does not see the new installation until you restart. If that does not work, uninstall Node.js (delete the installer .pkg file and restart), then try the Homebrew method instead. Homebrew handles permissions better on some Macs and is less likely to fail.