Node.js lets you run JavaScript outside the browser

βœ… Step-by-Step: Install Node.js on Windows (or Mac/Linux)


πŸ”Ή Step 1: Download Node.js

  1. Go to πŸ‘‰ https://nodejs.org

  2. 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

  1. Run the downloaded installer

  2. Click Next, accept license, and install everything with default options

  3. Keep the box β€œAdd to PATH” checked during install (important)

  4. 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:

bash
node -v

It should show something like:

v18.19.1

Now check npm (Node Package Manager):

bash
npm -v

Example:

9.5.0

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

  1. Open any folder in VS Code

  2. Create a file: app.js

  3. Add this code:

javascript
console.log("Hello from Node.js!");
  1. Open the terminal in VS Code (Ctrl + ~)

  2. Run the script:

bash
node app.js

πŸŽ‰ Output:

csharp
Hello from Node.js!

πŸ“¦ Bonus: Install a Package with npm

Example: Install a color library called chalk:

bash
npm install chalk

Then in app.js:

javascript
import chalk from 'chalk';

console.log(chalk.green('This text is green!'));

For this to work in newer Node versions, rename app.js to app.mjs or add "type": "module" in package.json


🧠 Summary

Tool Description
Node.js Runs JavaScript on your computer
npm Installs libraries and tools
VS Code Great editor for writing JS

Leave a Comment