home

🟒 Node.js & npm Installation Guide

πŸ“¦ What Are Node.js and npm?


🍏 macOS Installation

Make sure Homebrew is installed first.

πŸ“₯ Install Node.js + npm

brew install node

βœ… Verify Installation

node -v   # Should return a version like v20.x.x
npm -v    # Should return a version like 10.x.x

πŸͺŸ Windows Installation

βœ… 1. Download the Installer

βœ… 2. Verify Installation

Open Command Prompt (cmd) and run:

node -v
npm -v

🐧 Linux Installation (Ubuntu/Debian)

βœ… 1. Update Your System

sudo apt update

βœ… 2. Install Node.js and npm

sudo apt install nodejs npm

This installs both node and npm, but it might be an older version.

🧠 Optional: Install the Latest Version with NodeSource

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs

βœ… 3. Verify Installation

node -v
npm -v

πŸ§ͺ Test Installation

Create a simple JavaScript file:

echo "console.log('Node is working!');" > test.js
node test.js

Expected output:

Node is working!

πŸ› οΈ Updating npm

To update npm to the latest version:

npm install -g npm

🧰 Tips