What Node.js is and why you 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 building web applications, working with certain development tools, or following along with coding tutorials, you'll need Node.js installed before you can proceed.

When you install Node.js, you also get npm (Node Package Manager), which is a library of pre-written code that other developers have shared. Think of npm like an app store for code — it saves you from writing everything from scratch.

The installation process is straightforward and takes about five minutes on any operating system. The steps differ slightly depending on whether you use Windows, Mac, or Linux, so find your section below and follow it in order.

Key Takeaways

  • Node.js is downloaded from nodejs.org, and you should choose the LTS (Long Term Support) version unless you have a specific reason to use the latest version.
  • On Windows and Mac, you download an installer file and run it like any other program; on Linux, you use your system's package manager.
  • After installation, open a terminal or command prompt and type node --version to confirm everything worked.
  • If the version command fails, your system may not have restarted properly or the installer did not complete — uninstall and try again.

Installing Node.js on Windows

Go to nodejs.org in your web browser. You'll see two large download buttons. Click the one labeled LTS (Long Term Support) — this is the stable version that most people use. The page will download a file with a name like node-v20.x.x-x64.msi.

Find the downloaded file in your Downloads folder and double-click it. A window will open asking you to install Node.js. Click Next through each screen. When you reach the screen that says "Tools for Native Modules," leave the checkbox unchecked unless you know you need it — most people don't. Continue clicking Next until you see an Install button, then click it. Windows may ask for permission; click Yes.

When the installer finishes, close the window and restart your computer. This step matters — Node.js won't work properly until you restart.

After restart, open Command Prompt by pressing Windows key + R, typing cmd, and pressing Enter. Type this command and press Enter: node --version. If you see a version number like v20.10.0, the installation worked. If you see "command not found" or similar, restart your computer again and try the command once more.

Installing Node.js on Mac

Open a web browser and go to nodejs.org. Click the LTS download button. The page will download a file named something like node-v20.x.x.pkg.

Find the downloaded file in your Downloads folder and double-click it. An installer window will open. Click Continue through each screen, then click Install. Your Mac will ask for your password — type it and click Install Software. When the installer finishes, click Close.

Open Terminal by pressing Command + Space, typing terminal, and pressing Enter. In the terminal window, type this command and press Enter: node --version. You should see a version number like v20.10.0. If you see "command not found," close Terminal completely, wait 10 seconds, reopen it, and try the command again.

Installing Node.js on Linux

The installation method depends on which Linux distribution you use. Open a terminal window and run the command for your system.

For Ubuntu or Debian: Type these commands one at a time, pressing Enter after each:

  1. sudo apt update
  2. sudo apt install nodejs npm

For Fedora: Type this command:

  1. sudo dnf install nodejs npm

For Arch: Type this command:

  1. sudo pacman -S nodejs npm

Your system will ask for your password. Type it and press Enter. The package manager will download and install Node.js and npm automatically. When it finishes, type node --version and press Enter. You should see a version number.

Verifying the installation worked

After you've completed the steps for your operating system, you need to confirm that both Node.js and npm are working. Open a terminal (Mac or Linux) or Command Prompt (Windows) and type two commands:

First, type node --version and press Enter. You should see output like v20.10.0 or similar. Second, type npm --version and press Enter. You should see output like 9.8.1 or similar. If both commands show version numbers, you're ready to use Node.js.

If either command shows "command not found" or "is not recognized," the installation did not complete properly. On Windows or Mac, restart your computer and try the version commands again. On Linux, double-check that you typed the installation command correctly for your distribution.

What to do if the installation fails

The most common problem is that your computer hasn't restarted since installation. Restart and try the version command again — this solves the issue about 80 percent of the time.

If restarting doesn't work, uninstall Node.js completely and reinstall it. On Windows, go to Settings > Apps > Apps & Features, find Node.js in the list, click it, and click Uninstall. On Mac, open Finder, go to Applications, find Node.js, and drag it to Trash. On Linux, use your package manager to uninstall: sudo apt remove nodejs npm (Ubuntu/Debian), sudo dnf remove nodejs npm (Fedora), or sudo pacman -R nodejs npm (Arch). Then download and install again from nodejs.org or your package manager.

If you're still stuck after reinstalling, check that you downloaded the correct version for your system. On nodejs.org, the LTS button should automatically detect whether you need the Windows, Mac, or Linux version. If you see a 32-bit option, ignore it — almost all modern computers are 64-bit.

Frequently Asked Questions

Should I install the LTS version or the Current version?

Install LTS unless you have a specific reason not to. LTS stands for Long Term Support and receives security updates for years. The Current version gets new features faster but stops receiving updates after a few months. Most tutorials and projects use LTS.

Do I need to install npm separately?

No. npm comes automatically when you install Node.js. You don't need to download or install it separately.

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

Yes, but it requires extra tools like nvm (Node Version Manager) on Mac and Linux, or nvm-windows on Windows. Most people don't need this. Install one version and use it until you have a specific reason to switch.

What does "command not found" mean when I type node --version?

It means your computer can't find Node.js in the locations it searches. Usually this happens because you haven't restarted since installation. Restart your computer and try again. If it still doesn't work, the installer may have failed — uninstall and reinstall Node.js.

Is Node.js safe to install?

Yes. Node.js is open-source software maintained by the OpenJS Foundation and used by millions of developers. Download it only from nodejs.org to avoid fake versions.