β Step-by-Step: Install Node.js on Windows (or Mac/Linux)
πΉ Step 1: Download Node.js
-
Go to π https://nodejs.org
-
Youβll see two options:
-
LTS (Recommended for most users) β
-
Current (Latest features, but not always stable)
-
Choose the LTS version (green button)
πΉ Step 2: Install Node.js
-
Run the downloaded installer
-
Click Next, accept license, and install everything with default options
-
Keep the box βAdd to PATHβ checked during install (important)
-
Wait for it to finish, then click Finish
πΉ Step 3: Check if Node.js and npm are installed
Open Command Prompt (CMD) or Terminal and type:
It should show something like:
Now check npm (Node Package Manager):
Example:
If you see versions β you’re all set! β
π‘ What is Installed?
Tool | Purpose |
---|---|
node |
Lets you run JavaScript in terminal |
npm |
Manages packages and libraries |
π§ͺ Try Your First Node.js Script
-
Open any folder in VS Code
-
Create a file:
app.js
-
Add this code:
-
Open the terminal in VS Code (
Ctrl + ~
) -
Run the script:
π Output:
π¦ Bonus: Install a Package with npm
Example: Install a color library called chalk
:
Then in app.js
:
For this to work in newer Node versions, rename
app.js
toapp.mjs
or add"type": "module"
inpackage.json
π§ Summary
Tool | Description |
---|---|
Node.js | Runs JavaScript on your computer |
npm | Installs libraries and tools |
VS Code | Great editor for writing JS |