Installing Node.js
Before you can start building amazing things with Node.js, you need to install it on your computer. Don't worry – it's a simple process whether you're using Windows, Mac, or Linux. Let's get Node.js up and running!
What You'll Get
When you install Node.js, you get two important things:
- Node.js Runtime: The actual environment to run JavaScript code.
- npm: Node Package Manager – comes with Node.js and helps you install libraries.
Think of Node.js as the engine of a car, and npm as the GPS that helps you find and install parts (packages) for your car.
Installing on Windows
- Go to the official Node.js website: https://nodejs.org
- You'll see two versions: LTS (Long Term Support) and Current.
- Download the LTS version – it's more stable and recommended for beginners.
- Run the downloaded `.msi` installer file.
- Follow the installation wizard:
- Accept the license agreement- Choose installation location (default is fine)- Select components (keep default)- Click "Install"Installing on Mac
Method 1: Official Installer
- Go to https://nodejs.org
- Download the macOS installer (.pkg file).
- Open the downloaded file and follow the instructions.
Method 2: Using Homebrew (Recommended for developers)
brew install nodeInstalling on Linux
Ubuntu/Debian:
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -sudo apt-get install -y nodejsFedora/RHEL:
sudo dnf install nodejssudo dnf install npmVerifying Installation
After installation, open your terminal (Command Prompt on Windows, Terminal on Mac/Linux) and type:
node --versionnpm --versionYou should see version numbers like `v18.12.0` (for Node) and `8.19.2` (for npm). If you see these, congratulations – Node.js is successfully installed!
Your First Node.js Program
Create a new file called `hello.js` and add this line:
console.log("Hello, Node.js!");Now run it:
node hello.jsYou should see: `Hello, Node.js!`
Troubleshooting
| Problem | Solution |
|---|---|
| `node` is not recognized | Restart your terminal/computer. If still not working, add Node to PATH manually. |
| Permission denied (Linux/Mac) | Use `sudo` before commands or fix npm permissions. |
| Old version installed | Use `nvm` (Node Version Manager) to manage multiple versions. |
Two Minute Drill
- Download Node.js from nodejs.org (LTS version recommended).
- Installation is straightforward on Windows, Mac, and Linux.
- Verify installation with `node --version` and `npm --version`.
- Create a `.js` file and run it with `node filename.js`.
- Node.js comes with npm – the largest package ecosystem in the world!
Need more clarification?
Drop us an email at career@quipoinfotech.com
