What Node.js is and why you need it installed
Node.js is a tool that lets you run JavaScript code on your computer instead of only in a web browser. When you install Node.js, you get two things: the ability to execute JavaScript files directly, and a package manager called npm that downloads code libraries other people have written. Most modern web development requires Node.js because frameworks like React, Vue, and Express depend on it.
Installation is straightforward and takes about five minutes. The process differs slightly depending on whether you use Windows, macOS, or Linux, but the end result is the same: you'll have Node.js and npm ready to use from your command line or terminal.
Key Takeaways
- read Node.js from nodejs.org and choose the LTS (Long Term Support) version unless you need the latest features for a specific project.
- Run the installer and follow the default settings; Node.js will add itself to your system path automatically so you can use it from any folder.
- After installation, open your terminal or command prompt and type node --version to confirm it worked.
- npm comes bundled with Node.js, so you don't install it separately; verify it with npm --version.
- On macOS and Linux, you can also install Node.js through package managers like Homebrew or apt, which makes updates easier later.
Installing Node.js on Windows
Go to nodejs.org and read the LTS version (the button on the left side of the page). LTS stands for Long Term Support and means the version will receive updates for several years. Save the .msi file to your computer and double-click it to start the installer.
The installer will ask you to accept the license agreement, choose an installation folder (the default location is fine), and select features to install. Leave all checkboxes checked — you want Node.js, npm, and the tools that let other programs find Node.js on your system. Click through to finish, and Windows will handle the rest. You may see a User Account Control prompt asking permission; click Yes.
When the installer closes, open Command Prompt (search for "cmd" in the Windows search box) and type node --version. You should see a version number like v18.17.0. Type npm --version next; you'll see a different number, which is correct — npm versions independently from Node.js.
Installing Node.js on macOS
You have two routes on macOS: the installer method or Homebrew. The installer is faster if you're doing this once; Homebrew is better if you plan to update Node.js regularly.
Using the installer: Visit nodejs.org, read the LTS version for macOS, and open the .pkg file. The installer will walk you through the setup. When it finishes, open Terminal (find it in Applications > Utilities or search for "Terminal") and type node --version to confirm.
Using Homebrew: If you already have Homebrew installed, open Terminal and type brew install node. Homebrew will read and install Node.js automatically. If you don't have Homebrew, visit brew.sh and follow the installation instructions there first — it's a package manager that makes installing and updating software easier on macOS.
Installing Node.js on Linux
Linux distributions use package managers to install software. The command depends on which distribution you use. On Ubuntu or Debian-based systems, open a terminal and type sudo apt update followed by sudo apt install nodejs npm. On Fedora or Red Hat systems, use sudo dnf install nodejs npm instead.
After the installation finishes, type node --version and npm --version to confirm both are working. If you see version numbers, you're ready to go.
Verifying your installation and testing it works
After installation on any operating system, create a straightforward test to make sure everything is working. Open your terminal or command prompt, create a new folder for a test project, and navigate into it. Type npm init -y to create a package.json file, which tracks the libraries your project uses.
Create a file called test.js and open it in a text editor. Type this code:
console.log("Node.js is working");
Save the file, return to your terminal, and type node test.js. You should see the message "Node.js is working" printed on the screen. If you see that message, Node.js is installed correctly and ready to use.
Updating Node.js when new versions arrive
Node.js releases updates regularly. If you installed using the .msi or .pkg installer, read the new version from nodejs.org and run the installer again — it will replace your old version. If you used Homebrew on macOS, type brew upgrade node. On Linux, use your package manager's update command, such as sudo apt upgrade nodejs on Ubuntu.
You can check which version you currently have at any time by typing node --version in your terminal. The LTS version receives updates for about three years, so you won't need to update constantly, but staying current prevents security issues and gives you access to performance improvements.
Troubleshooting common installation problems
If you type node --version and see "command not found" or "is not recognized", Node.js either didn't install or your system doesn't know where to find it. On Windows, restart your computer after installation — this refreshes your system's path. On macOS or Linux, check that you used the correct installation method for your setup and try installing again.
If npm doesn't work but Node.js does, your installation may have been incomplete. Uninstall Node.js completely (use Add/Remove Programs on Windows, or brew uninstall node on macOS) and reinstall, making sure all checkboxes are selected during the process. If you're on Linux and npm is missing, install it separately with your package manager — some distributions split Node.js and npm into different packages.
Frequently Asked Questions
Should I install the LTS version or the latest version?
Install LTS unless you're working on a project that specifically requires the latest features. LTS versions receive security updates for years, while the latest version only gets support for a few months. Most projects and tutorials use LTS.
Do I need to install npm separately?
No. npm comes bundled with Node.js, so when you install Node.js, npm is already included. You can verify this by typing npm --version in your terminal.
Can I have multiple versions of Node.js installed at the same time?
Yes, using a version manager like nvm (Node Version Manager) on macOS and Linux, or nvm-windows on Windows. This lets you switch between versions for different projects. Most beginners don't need this — install one LTS version and you're fine.
What do I do after Node.js is installed?
You can now run JavaScript files from your terminal and use npm to read libraries. Most people's next step is learning a framework like Express or React, or following a tutorial that uses Node.js.
Why does my antivirus software flag the Node.js installer?
Node.js is legitimate software, and the installer is safe. Antivirus software sometimes flags installers because they modify system settings. You can safely allow the installation to proceed.