Course එකට ආපසු

Installing Node.js

20 මිනිත්තු🏋️Activity

Installing Node.js

Node.js is a JavaScript runtime that lets you run JavaScript outside of a web browser.


What is Node.js?

Node.js Explained

Traditionally:

  • JavaScript only ran in browsers
  • You couldn't use JS for server-side tasks
  • Limited to web pages only

With Node.js:

  • Run JavaScript anywhere on your computer
  • Build servers, tools, and scripts
  • Access your file system
  • Use thousands of free packages

In This Course:

What We'll Use Node.js For
Running local development servers
Using build tools
Installing packages with npm
Running JavaScript utilities

What is npm?

npm = Node Package Manager

When you install Node.js, you also get npm — a tool for installing pre-built code packages.

Think of npm as:

  • An app store for code
  • Contains millions of free packages
  • One command installs complex tools
  • Industry standard for JavaScript projects

Example Commands:

Bash
npm install prettier # Installs Prettier code formatter
npm install tailwindcss # Installs Tailwind CSS framework
npm install react # Installs React library

You'll use npm throughout your development career!


Installation Instructions

Choose your operating system:

Windows
# Windows Installation
## Step 1: Download
1. Open your browser
2. Go to: nodejs.org
3. You'll see two download options:
- LTS (Long Term Support) ← Choose this!
- Current (newer but less stable)
4. Click the LTS button (green)
5. The .msi installer will download
## Step 2: Run Installer
1. Find the downloaded file (e.g., node-v20.10.0-x64.msi)
2. Double-click to run
3. Click Next through the wizard
4. Accept the license agreement
5. Keep default installation path
6. Keep default features selected
7. IMPORTANT: Check "Automatically install necessary tools" if prompted
8. Click Install
9. Click Finish
## Step 3: Restart VS Code
If VS Code is open, close and reopen it.
This ensures VS Code recognizes the new installation.

Verification

After installation, let's verify everything works.

Open Terminal in VS Code:

  1. Open VS Code
  2. Open Terminal: View → Terminal or press Ctrl/Cmd + `

Check Node.js Version:

Bash
node --version

Expected output (version numbers may vary):

v20.10.0

If you see a version number starting with v, Node.js is installed!

Check npm Version:

Bash
npm --version

Expected output:

10.2.3

If you see a version number, npm is installed!


Troubleshooting


Test npm

Let's verify npm works by checking what it can do:

Bash
npm help

You should see a list of available npm commands.

Check Where Things Are Installed:

Bash
npm root -g

This shows where global packages are installed.


Version Reference

At time of writing, recommended versions:

SoftwareRecommended Version
Node.jsv18.x or v20.x (LTS)
npmv9.x or v10.x

Don't worry if your versions are slightly different — as long as the commands work, you're good!


Installation Checklist

Node.js Installation Verification

0/6

Screenshot Your Success

Take a screenshot showing the terminal with both version commands working.


What You Can Do Now

With Node.js installed, you can:

1. Run JavaScript files directly:

Bash
node myfile.js

2. Install packages globally:

Bash
npm install -g package-name

3. Create projects with package management:

Bash
npm init
npm install some-package

4. Use modern development tools that require Node.js


Lesson Summary

What You Accomplished:

  • ✅ Understand what Node.js is (JavaScript runtime)
  • ✅ Understand what npm is (package manager)
  • ✅ Installed Node.js on your computer
  • ✅ Verified installation with version checks

Why This Matters

Node.js is the foundation for modern JavaScript development. Many tools, frameworks, and workflows depend on it.


Knowledge Check

📝 Quiz

1/2

What is Node.js used for?


Next Up

Let's install Git — the version control system for tracking and saving your code changes!