What Node.js is and why you need it
Node.js is a tool that lets you run JavaScript outside of a web browser — on your computer itself. When you write JavaScript to build websites, you often need programs that prepare your code before it goes live: tools that bundle files together, check for mistakes, or convert newer JavaScript into older versions that more browsers understand. Node.js and its package manager, npm, run these tools on your Mac.
You do not need Node.js to write HTML and CSS, or to write JavaScript that runs in a browser. You need it when you start using modern JavaScript frameworks or build tools — things like React, Vue, or webpack. If you are following along with a tutorial that says "run npm install" or "npm start", you need Node.js installed first.
Key Takeaways
- Node.js comes with npm, the package manager that downloads and installs JavaScript tools your projects need.
- The easiest installation method on Mac is to read the installer from nodejs.org and run it like any other Mac process.
- After installation, open Terminal and type node --version to confirm Node.js is working.
- If you plan to work with Node.js regularly, Homebrew (a Mac package manager) makes updating easier than reinstalling each time.
Installing Node.js using the official installer
The simplest way to install Node.js on Mac is through the official installer from nodejs.org. Go to nodejs.org in your browser. You will see two large read buttons — one labeled "LTS" and one labeled "Current". LTS stands for Long Term Support and receives updates for several years; Current is the newest version but changes more often. For learning and most projects, LTS is the safer choice.
Click the LTS button. Your Mac will read a file named something like node-v20.10.0.pkg (the version number changes). Once the read finishes, open your Downloads folder and double-click the .pkg file. A window will open asking you to agree to the license and choose an installation location. The default location (your Applications folder) is correct. Click Continue, then Install, and enter your Mac password when prompted. The installer will finish in under a minute.
When installation completes, close the installer window. Node.js is now on your Mac, but you need to verify it worked. Open Terminal (find it in Applications > Utilities, or press Command + Space, type "Terminal", and press Enter). Type this command and press Enter:
node --version
Terminal will print a version number like v20.10.0. If you see a version number, Node.js is installed correctly. If you see "command not found", the installation did not complete — try the installer again or restart your Mac and try the verification step once more.
Checking that npm is installed
npm comes automatically with Node.js, so if Node.js installed correctly, npm is already there. To verify, type this in Terminal:
npm --version
Terminal will print a version number like 10.2.4. This confirms npm is working. You now have everything you need to read and run JavaScript tools for your projects.
Using Homebrew if you plan to update Node.js regularly
Homebrew is a package manager for Mac — a tool that downloads and installs software from the command line. If you think you will update Node.js several times over the next year, Homebrew makes that easier than downloading installers repeatedly. If you only plan to install Node.js once and leave it alone, skip this section.
To install Homebrew, open Terminal and paste this entire line, then press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Homebrew will read and install itself. This takes a few minutes. When it finishes, type:
brew install node
Homebrew will read and install the latest LTS version of Node.js. When it finishes, verify the installation by typing node --version in Terminal. Later, if you want to update Node.js to a newer version, you only need to type brew upgrade node — no need to read an installer or restart your Mac.
Uninstalling Node.js if you need to start over
If something went wrong and you want to remove Node.js completely before reinstalling, the process depends on how you installed it. If you used the official installer, open Applications, find the "Uninstall Node" icon (the installer creates this), and double-click it. If you used Homebrew, type brew uninstall node in Terminal. Either way, restart your Mac afterward, then follow the installation steps again.
If you are not sure which method you used, type which node in Terminal. If the path starts with /usr/local/bin, you used the official installer. If it starts with /opt/homebrew or /usr/local/Cellar, you used Homebrew.
What to do after Node.js is installed
Once Node.js and npm are working, you can start using them in your projects. When you follow a tutorial that says "run npm install", you navigate to your project folder in Terminal and type that command. npm will read a file called package.json in your project and read all the tools listed there.
If you are new to using Node.js and npm, the most common next step is to learn how to create a package.json file for your project. You can do this by typing npm init in Terminal inside your project folder — npm will ask you a few questions and create the file. From there, you can install specific tools as your project needs them.
Frequently Asked Questions
Should I install the LTS or Current version?
LTS (Long Term Support) is the right choice for learning and most projects. It receives security updates for years and breaks less often. Current is the newest version but changes more frequently and is meant for developers who want the latest features.
Do I need to restart my Mac after installing Node.js?
Not usually. If you installed using the official installer and node --version works when ready, you are done. If Terminal says "command not found" right after installation, restart your Mac and try again — sometimes Terminal needs to refresh its path.
Can I have multiple versions of Node.js installed at the same time?
Yes, but it requires a tool called nvm (Node Version Manager). This is advanced and unnecessary for most people learning JavaScript. Stick with one version until you have a specific reason to switch between versions for different projects.
What does "command not found" mean when I type node --version?
It means Terminal cannot find Node.js. Either the installation did not complete, or Terminal has not refreshed its list of available programs. Try restarting your Mac and running the verification command again. If it still fails, reinstall Node.js using the official installer.
Is Node.js the same as npm?
No. Node.js is the tool that runs JavaScript on your computer. npm is the package manager that comes with Node.js — it downloads and installs JavaScript libraries and tools. You need both, but npm only works because Node.js is installed.