Web Development Tutorial

Node.js Get Started: Install, Setup And Run Your First App (2026-27)

By Pramod Behera  ·  Updated: July 2026  ·  16 min read
✅ In this Web Technologies Tutorial - Node.js Get Started: How To Install, Set Up And Run Your First App

This guide picks up right where our Node.js Introduction left off. If you already understand what Node.js is and why it exists, the next step is getting it running on your own machine. In this tutorial we walk through installing Node.js on Windows, macOS and Linux, verifying the installation, choosing between LTS and Current, setting up a code editor, exploring the interactive REPL, creating your first package.json, installing packages with npm, building a tiny web server, and avoiding the mistakes most beginners make. This tutorial finishes with a getting-started checklist, an interactive code playground, a quiz, and an FAQ.

📋 Table of Contents

  1. What You'll Need Before You Start
  2. Installing Node.js (Windows, macOS, Linux)
  3. Verifying Your Installation
  4. Choosing LTS vs. Current
  5. Setting Up a Code Editor
  6. Your First Node.js Script
  7. Using the Node.js REPL
  8. Creating Your First Project
  9. Installing And Using npm Packages
  10. Building a Simple Web Server
  11. Environment Variables And Configuration
  12. Debugging a Node.js App
  13. Recommended Project Structure
  14. Common Beginner Mistakes
  15. Getting Started Checklist
  16. Quick Reference Table
  17. Try It Yourself: Code Playground
  18. Practice Quiz
  19. Frequently Asked Questions (FAQ)

✅ What You'll Need Before You Start

Getting started with Node.js does not require any special hardware or paid software. Almost any modern computer running Windows, macOS, or Linux is enough. Before you begin, it helps to have the following ready:

ℹ️ Quick definition: "Getting started" with Node.js really means three things - installing the Node.js runtime on your machine, confirming it works, and running your first piece of JavaScript through it. Everything else in this guide builds on those three steps.

✅ Installing Node.js (Windows, macOS, Linux)

Node.js provides official installers for every major operating system, and the process takes only a few minutes on any of them.

🪟 Windows

Go to nodejs.org, download the Windows Installer (.msi) for the LTS version, and run it. Accept the default options - this also adds Node.js and npm to your system PATH automatically, so both commands work from any Command Prompt or PowerShell window.

🍎 macOS

Download the macOS Installer (.pkg) from nodejs.org and run it like any other application installer. Alternatively, if you use Homebrew, you can install Node.js with a single terminal command: brew install node.

🐧 Linux

Most Linux distributions offer Node.js through their package manager, though the bundled version can be older. For a current LTS release, use your distribution's NodeSource setup script, or a version manager such as nvm, which many Linux developers prefer.

💡 Tip: If you expect to work on multiple projects that need different Node.js versions, install nvm (Node Version Manager) instead of installing Node.js directly. It lets you switch versions per project with a single command and avoids permission issues that sometimes come with system-wide installs.

✅ Verifying Your Installation

Once the installer finishes, open a terminal (Command Prompt, PowerShell, Terminal, or your Linux shell) and run the following two commands:

// Check the installed Node.js version
node -v

// Check the installed npm version
npm -v

Also If both commands print a version number - something like v22.14.0 and 10.9.2 - your installation succeeded and Node.js is ready to use. If you instead see a "command not found" or "not recognized" error, the most common fix is to close and reopen your terminal so it picks up the updated PATH, or to restart your computer if that doesn't help.

⚠️ Common pitfall: Installing Node.js while a terminal window is already open will not update that window's PATH automatically. Always open a fresh terminal window before verifying the installation.

✅ Choosing LTS vs. Current

The Node.js download page usually offers two options, and it's worth understanding the difference before you pick one.

VersionBest For
LTS (Long Term Support)Beginners, learning projects, and production applications. Receives stability and security updates for years.
CurrentDevelopers who want to try the newest JavaScript and Node.js features early, accepting that changes happen more often.

Unless you have a specific reason to need a brand-new feature, choose LTS. Almost every tutorial, package, and production deployment guide assumes you are running an LTS release, so it minimizes the chance of running into confusing compatibility issues while you are still learning.

✅ Setting Up a Code Editor

Node.js code can technically be written in any plain text editor, but a proper code editor makes learning far smoother. Visual Studio Code (VS Code) is the most widely used option in the Node.js community and is free to download.

🖊️
Syntax Highlighting
Color-codes your JavaScript so typos and structure are easier to spot at a glance.
🧠
IntelliSense
Suggests function names, parameters, and built-in module methods as you type.
⚙️
Integrated Terminal
Run node app.js and npm commands without leaving the editor window.

Once installed, open your project's folder in VS Code using File → Open Folder, then use the built-in terminal (Terminal → New Terminal) to run the same node and npm commands you would use in a standalone terminal window.

✅ Your First Node.js Script

With Node.js installed and verified, it's time to run actual code. Create a new folder for your project, then inside it create a file named app.js with the following content:

console.log("Hello, Node.js!");

Open a terminal inside that same folder and run:

node app.js

You should immediately see Hello, Node.js! printed in the terminal. That's it - you've just executed JavaScript entirely outside of a web browser, which is the whole point of Node.js.

✅ Using the Node.js REPL

Besides running saved files, Node.js ships with an interactive prompt called the REPL (Read-Eval-Print Loop). It's useful for quickly testing a line of JavaScript without creating a file at all. Start it by typing node with no filename:

// Start the REPL
node

// Then type JavaScript directly and press Enter
> 2 + 2
4
> const name = "Node.js learner";
undefined
> console.log(`Hi, ${name}!`);
Hi, Node.js learner!

Each line you type is read, evaluated, and the result is printed immediately - hence "Read-Eval-Print Loop." To exit the REPL, press Ctrl + C twice, or type .exit and press Enter.

💡 Tip: The REPL is great for quick experiments - checking how a method behaves, testing a regular expression, or confirming syntax - but real projects should always live in saved .js files, not in REPL history.

✅ Creating Your First Project

A real Node.js project starts with a package.json file, which acts as its manifest. Inside your project folder, run:

npm init -y

The -y flag accepts all the default answers instantly. Without it, npm init asks you a series of questions - project name, version, description, entry point, and so on - and writes your answers into the same file. Either way, you'll end up with something like this:

{
  "name": "my-first-node-app",
  "version": "1.0.0",
  "description": "",
  "main": "app.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

From this point on, every package you install and every custom script you define will be recorded automatically inside this file, which makes it easy for anyone else - or a future version of you - to recreate the exact same project setup.

✅ Installing And Using npm Packages

npm, installed automatically with Node.js, gives you access to well over a million open-source packages. Installing one is a single command:

npm install express

This downloads the Express.js framework into a local node_modules folder and adds it as a dependency inside package.json. Once installed, you can import and use it in your code:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello from Express!');
});

app.listen(3000, () => {
  console.log('App listening on port 3000');
});
⚠️ Important: The node_modules folder can grow to thousands of files even for small projects. It should never be committed to version control - add it to a .gitignore file instead. Anyone who clones your project can recreate it instantly by running npm install, since package.json already lists every dependency.

✅ Building a Simple Web Server

You do nit even need a third-party framework to build a working web server - Node.js includes a built-in http module for exactly this purpose:

const http = require('http');

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello from my first Node.js server!');
});

server.listen(3000, () => {
  console.log('Server running at http://localhost:3000/');
});

Save this as server.js, run node server.js, then open a browser and go to http://localhost:3000/. You should see the plain text response rendered on the page. Press Ctrl + C in the terminal whenever you want to stop the server.

✅ Environment Variables And Configuration

Real applications need configuration that changes between your laptop and a live server - things like port numbers, database URLs, or API keys. Node.js exposes these through process.env:

// Reading an environment variable safely, with a fallback
const port = process.env.PORT || 3000;
console.log(`Server will run on port ${port}`);

You can set a variable temporarily before running a command - for example, PORT=4000 node server.js on macOS and Linux - or store them in a local .env file loaded by a package such as dotenv. Either approach keeps sensitive values, like API keys, out of your source code.

ℹ️ Why this matters early: Getting comfortable with process.env now saves confusion later, since almost every real deployment platform configures apps through environment variables rather than hard-coded values.

✅ Debugging a Node.js App

When something goes wrong, Node.js gives you a few beginner-friendly ways to find out why, without installing anything extra.

🖨️ console.log Debugging

The simplest technique: print variable values at key points in your code to see what's actually happening at runtime.

🐞 The Built-In Inspector

Run node --inspect app.js, then open chrome://inspect in Chrome to set breakpoints and step through code visually.

🧩 VS Code Debugger

VS Code has a built-in Node.js debugger - click to the left of a line number to set a breakpoint, then press F5 to run your file with debugging attached.

Reading the error message and stack trace carefully is often the fastest fix of all: Node.js errors usually point to the exact file and line number where something failed, along with a description of what went wrong.

✅ Recommended Project Structure

Even a small Node.js project benefits from a little organization from day one. A simple, common layout looks like this:

my-first-node-app/
├── node_modules/     // installed packages (never edit or commit)
├── src/
│   └── app.js        // your application code
├── .env               // local environment variables (never commit)
├── .gitignore          // tells Git to ignore node_modules and .env
├── package.json        // project manifest and dependencies
└── package-lock.json    // exact installed versions, auto-generated

You don't need this exact structure for a one-file experiment, but adopting it early - especially the .gitignore file - builds habits that carry directly into larger, real-world projects.

✅ Common Beginner Mistakes

✅ Getting Started Checklist

💡 Before moving on, make sure you can check off each of these:

✔️ Node.js and npm are installed and node -v / npm -v both print a version number.
✔️ You've run at least one script successfully with node app.js.
✔️ You've opened and exited the Node.js REPL at least once.
✔️ You have a code editor set up with an integrated terminal.
✔️ You've created a package.json with npm init.
✔️ You've installed at least one package with npm install.
✔️ You understand why node_modules should not be committed to version control.

✅ Node.js Get Started - Quick Reference Table

Command / TermOne-Line Meaning
node -vPrints the installed Node.js version.
npm -vPrints the installed npm version.
node app.jsRuns a saved JavaScript file with Node.js.
nodeOpens the interactive REPL.
npm init -yCreates a package.json with default values.
npm install <pkg>Installs a package and adds it to package.json.
node_modulesFolder containing installed package code - never commit it.
package-lock.jsonAuto-generated file locking exact dependency versions.
process.envObject used to read environment variables at runtime.
node --inspectRuns a script with the debugger enabled for Chrome DevTools.

✅ Try It Yourself: Code Game Playground

Edit the JavaScript below and click "Run" to see simulated console output. This demonstrates basic JavaScript concepts you would run identically inside Node.js using node yourfile.js.


Output will appear here...

✅ Practice - Yes / No Quiz

1. Does installing Node.js also install npm automatically?

2. Should beginners generally choose the "Current" version over "LTS" when installing Node.js?

3. Does typing node with no filename start the interactive REPL?

4. Should the node_modules folder normally be committed to version control?

5. Does npm init -y create a package.json file using default values?

0/5
Your Score - Keep Practising! 🎯

✅ Frequently Asked Questions (FAQ)

Do I need to install anything besides Node.js to start coding?
No. Installing Node.js also installs npm automatically, and that is enough to write and run JavaScript files from your terminal. A code editor like VS Code makes the process more comfortable but is not strictly required.
Should I install the LTS or the Current version of Node.js?
Beginners and production projects should install the LTS (Long Term Support) version, since it receives stability and security updates over a longer period. The Current version has the newest features but changes more often.
What is the difference between running node app.js and using the REPL?
Running node app.js executes a saved JavaScript file from start to finish. The REPL, started by typing node with no filename, is an interactive prompt for testing small snippets of code line by line without creating a file.
What does npm init actually create?
npm init creates a package.json file, which is the manifest for your project. It records the project name, version, entry point, scripts, and the list of dependencies your project relies on.
Why does my project have a node_modules folder?
The node_modules folder is created automatically the first time you install a package with npm install. It stores the actual code for every package your project depends on, and is normally excluded from version control using a .gitignore file.
✍️ About the Author - Pramod Behera

Pramod Behera is the founder of LearnToSAP.com and an experienced technology educator. He creates beginner-friendly tutorials spanning SAP modules, web development, and Cyber Security, helping thousands of learners worldwide build practical, job-ready skills.