How to Install Node.js: A Step-by-Step Beginner Guide

Written by

in

TL;DR: Install Node.js by downloading the LTS version from the official website and running the installer, or by using a version manager like nvm for greater flexibility. After installation, verify it works by typing node -v and npm -v in your terminal.

Step 1: Choose Your Installation Method

There are two primary ways to install Node.js: the official installer (easiest for beginners) or a version manager like nvm (recommended if you plan to work on multiple projects with different Node versions). For this guide, we’ll focus on the official installer first, then briefly cover nvm.

If you want to dig deeper, check out our guide on Shopify Store Audit: Fix 5 Leaks Killing Your Ecommerce Sale.

Step 2: Download the Installer

Go to nodejs.org and click the big green button labeled “LTS” (Long-Term Support). LTS is the stable, production-ready version—avoid the “Current” version unless you need bleeding-edge features. The site will detect your OS (Windows, macOS, or Linux) and offer the correct installer file.

Step 3: Run the Installer

Double-click the downloaded file (e.g., node-v20.x.x.pkg on macOS or .msi on Windows). Follow the default prompts. Important: leave the “Add to PATH” checkbox checked (Windows) or accept the default installation location (macOS/Linux). This ensures node and npm commands work from any terminal. Click “Next” until installation completes.

Step 4: Verify Installation

Open a new terminal (Command Prompt on Windows, Terminal on macOS/Linux). Type node -v and press Enter. You should see a version number like v20.11.1. Then type npm -v—this prints the npm (Node Package Manager) version, confirming both tools are ready. If you get “command not found,” restart your terminal or reboot your computer.

Step 5: Test with a Simple Script

Create a file named test.js with console.log("Hello Node!");. In the terminal, navigate to that folder and run node test.js. You should see “Hello Node!” printed. This confirms your installation is fully functional.

Step 6: (Optional) Install via nvm for Version Control

If you prefer nvm, first uninstall the official Node.js, then install nvm using the curl command from the nvm GitHub page. After installing nvm, run nvm install --lts and then nvm use --lts. This lets you switch versions easily with nvm use 18 or nvm install 21.

Pro Tip: Always use the LTS version for production projects. Check for updates every few months—Node.js releases a new LTS every even-numbered year (e.g., 20.x in 2024).

FAQ

Q: Do I need to install npm separately?
A: No. npm is bundled with Node.js. When you install Node.js, npm is installed automatically—that’s why npm -v works right after installation.

Q: Why do I get “EACCES” permission errors when installing packages?
A: That happens if you installed Node.js with sudo or as root. The fix is to reinstall using the official installer (which doesn’t require sudo) or use nvm, which installs Node in your user directory, avoiding permission conflicts entirely.

Q: Can I install Node.js on a Raspberry Pi or other ARM devices?
A:

Related Articles

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *