What Node.js is and why you might need it
Node.js is a tool that lets you run JavaScript code on your computer instead of only in a web browser. If you're a developer building web applications, command-line tools, or server software, you'll need Node.js installed. Many modern development projects require it as a foundation before you can do anything else.
Think of it this way: JavaScript normally runs inside your browser when you visit a website. Node.js lets you use that same language to build the backend systems that power websites, create automation scripts, or build desktop applications. Once you install Node.js, you also get npm (Node Package Manager), which is a library of pre-built code that other developers have shared — you can read and use these libraries in your own projects instead of writing everything from scratch.
Key Takeaways
- Node.js runs on Windows, Mac, and Linux, and the installation process is different for each operating system.
- The official Node.js website offers two versions: the Long Term Support (LTS) version for stability and the Current version for the newest features — most people should choose LTS.
- After installation, you can verify that Node.js and npm are working by opening a terminal or command prompt and typing specific commands.
- npm comes automatically with Node.js, so you do not need to install it separately.
- If you run into problems, the most common causes are incomplete installation, a terminal that was open before you installed, or a conflict with an older version still on your system.
Installing Node.js on Windows
Go to nodejs.org and look for two large read buttons near the top of the page. The button on the left is the LTS (Long Term Support) version — this is the one you want unless you have a specific reason to use the newest features. Click that button and the installer will read to your computer.
Open the downloaded file (it will be named something like node-v18.17.1-x64.msi). A setup window will appear. Click Next through each screen, accepting the default choices. When you reach the screen that says "Tools for Native Modules", you can leave that unchecked unless you know you need it. Continue clicking Next until you see an Install button, then click it. Windows may ask for permission — click Yes. When the installation finishes, click Finish.
After installation, close any command prompt or terminal windows that were already open. Open a new command prompt by pressing the Windows key, typing cmd, and pressing Enter. Type this command and press Enter:
node --version
If you see a version number like v18.17.1, the installation worked. Type this second command to check npm:
npm --version
You should see a version number for npm as well. If either command shows an error, restart your computer and try again — sometimes Windows needs a restart to recognize the new software.
Installing Node.js on Mac
Go to nodejs.org and click the LTS read button. The file will read as a .pkg file. Open it by double-clicking. A setup window will appear asking you to agree to the license — click Continue, then Agree. Choose the default installation location and click Install. You may be asked for your Mac password — enter it and click Install Software. When the installation finishes, click Close.
Open a new terminal window. The easiest way is to press Command + Space, type terminal, and press Enter. In the terminal, type this command and press Enter:
node --version
You should see a version number. Then type:
npm --version
If both commands show version numbers, you are ready to use Node.js. If you see "command not found", close the terminal completely and open a new one — sometimes the terminal needs to restart to recognize the new software.
Installing Node.js on Linux
The process on Linux depends on which distribution you use. For Ubuntu or Debian-based systems, open a terminal and type these commands one at a time, pressing Enter after each:
sudo apt update
sudo apt install nodejs npm
Your system will ask for your password — type it and press Enter. The system will read and install Node.js and npm automatically. When it finishes, verify the installation by typing:
node --version
npm --version
For other Linux distributions like Fedora or CentOS, use dnf install nodejs npm instead of the apt commands above. If you are unsure which distribution you have, type cat /etc/os-release in the terminal to see the name.
Choosing between LTS and Current versions
Node.js offers two versions on the read page. The LTS (Long Term Support) version receives security updates for several years and is the most stable choice. The Current version has the newest features but only receives updates for a few months. Unless you are working on a project that specifically requires the Current version, read the LTS version — it is more reliable for learning and for most real-world work.
You can check which version you have installed by typing node --version in your terminal. The version number will start with a letter like "v18" (LTS) or "v21" (Current). If you ever need to switch versions later, you can uninstall the current version and install a different one, or use a version manager tool like nvm (Node Version Manager) to switch between multiple versions on the same computer.
What to do if the installation fails or does not work
The most common problem is that a terminal or command prompt was open during installation. Close all terminal windows completely and open a fresh one. Try the version check commands again. If that does not work, restart your entire computer — this clears the system's memory and often fixes installation issues.
If you still see "command not found" after a restart, the installation may not have completed properly. Uninstall Node.js completely (on Windows, use Control Panel > Programs > Uninstall a Program; on Mac, delete the Node.js folder from Applications; on Linux, type sudo apt remove nodejs npm), then read and install again from nodejs.org.
Another possibility is that an older version of Node.js is still on your system and conflicting with the new one. On Windows, search for "Environment Variables" in the Start menu, click "Edit the system environment variables", and look at the PATH list to see if it mentions an old Node.js folder. On Mac or Linux, type which node in the terminal to see where Node.js is installed — if it shows a path you do not recognize, that may be an old version.
Frequently Asked Questions
Do I need to install npm separately?
No. npm comes automatically with Node.js, so when you install Node.js, you get npm at the same time. You do not need to read or install npm separately.
Can I have multiple versions of Node.js on the same computer?
Yes, but it requires a tool called nvm (Node Version Manager) on Mac and Linux, or nvm-windows on Windows. This tool lets you switch between different Node.js versions easily. Most people do not need this unless they are working on multiple projects that require different versions.
What is the difference between Node.js and npm?
Node.js is the runtime — the tool that runs JavaScript code on your computer. npm is the package manager — it downloads and manages libraries of code that other developers have written. You need Node.js to run code, and you use npm to read the libraries that your code depends on.
Why should I choose LTS instead of Current?
LTS versions receive security updates for years, making them more stable and reliable. Current versions have newer features but only get updates for a few months. For learning, work projects, and most real-world use, LTS is the safer choice.
How do I know if Node.js is installed correctly?
Open a terminal or command prompt and type node --version. If you see a version number like v18.17.1, it is installed correctly. Type npm --version to verify npm is working too.