Free Online Course · Self-paced · Hands-on

Node.js Tutorial for Beginners (Hands-On)

Free Node.js tutorial for beginners: 60 hands-on lessons on files, async code, HTTPS servers, Express, MongoDB, MySQL, Passport login, and deployment.

  • 11 chapters
  • 60 lessons
  • ~11h
  • Beginner to Intermediate
  • Tested with Node.js 22.x, 24.x
  • Updated Sep 2026
Node.js Tutorial for Beginners (Hands-On)
By Last updated

About this course

This is a free, self-paced Node.js course for developers who already know JavaScript and want to use it on the server. It covers the runtime and REPL, the file system, asynchronous patterns, HTTP and HTTPS servers, Express with MongoDB and MySQL, authentication, debugging, and deployment. Install a current LTS release from nodejs.org before you start; Node.js 24 is the newest LTS line.

The lessons are small, runnable programs rather than one large application you have to keep in sync. Create a fresh folder for each chapter, run npm init -y, and install only the packages that lesson names. Dependency trees stay small that way, and a broken package in one lesson cannot affect the next.

If Node.js is new to you, work through the chapters in order, because the Express chapters assume the file system and async lessons. If you already write Node.js, jump to async loops, the Express and databases chapter, or the error handling and debugging chapter.

What you'll learn

  • Install Node.js, use the REPL, and read environment variables and global objects
  • Create, read, list, and write files and directories with the fs and path modules
  • Loop over asynchronous work with callbacks, promises, and async/await, and use worker threads for CPU-heavy tasks
  • Make HTTP requests and run an HTTPS server with Node's built-in modules
  • Build Express routes that read POST bodies, accept file uploads, and store data in MongoDB or MySQL
  • Add user login with Passport.js and paginate large collections with Mongoose
  • Spawn child processes, handle errors, and fix "Cannot find module" failures
  • Test code with the assert module and deploy an application to Heroku

Who this course is for

  • Front-end developers who know JavaScript and want to write the API behind their pages
  • Full-stack developers who want one language across the browser, the server, and build scripts
  • Sysadmins and DevOps engineers writing file, process, and HTTP automation in JavaScript
  • Developers from PHP or Python backends who need to read and maintain Express applications

Prerequisites

  • JavaScript fundamentals, including callbacks, promises, and async/await; the JavaScript course covers them
  • A Linux, macOS, or Windows machine with a current Node.js LTS release, installed through nvm if you switch versions between projects
  • Comfortable at the command line with npm init, npm install, and running package scripts
  • A local MongoDB or an Atlas cluster, and MySQL, only for the database chapters

Versions and testing environment

Every command in this course was run on this stack

ComponentVersionNotes
Node.js 22.x, 24.x The install lesson ran Node.js 22.22.1 from Ubuntu's apt repository and 24.18.0 through nvm; some older lessons still show Node.js 18 output
Ubuntu 26.04 LTS Host for the install lesson; the other lessons run the same way on macOS and Windows
Express 4.x The package.json files in the Express lessons pin ^4.17 and ^4.18

Syllabus

11 chapters · 60 lessons · ~11h of reading

  1. 1 Installation and First Steps 7 lessons · ~42 min
    1. Part 1 Install Node.js on Ubuntu 10 min read
    2. Part 2 How to use the Node.js REPL 7 min read
    3. Part 3 Run the REPL inside a function 6 min read
    4. Part 4 Node.js global objects explained 6 min read
    5. Part 5 Read environment variables 5 min read
    6. Part 6 Pass arguments to an npm script 4 min read
    7. Part 7 println() equivalent in Node.js 4 min read
  2. 2 Editor Setup 4 lessons · ~24 min
    1. Part 8 Set up Node.js with VS Code 7 min read
    2. Part 9 Set up Node.js with Eclipse IDE 7 min read
    3. Part 10 Set up Node.js with Atom IDE 5 min read
    4. Part 11 Set up Node.js with Sublime Text 5 min read
  3. 3 File System 11 lessons · ~1h 3m
    1. Part 12 Create a directory if it doesn't exist 5 min read
    2. Part 13 Check if a file or directory exists 5 min read
    3. Part 14 List all files in a directory 6 min read
    4. Part 15 List files recursively 6 min read
    5. Part 16 Loop through files in a directory 7 min read
    6. Part 17 Read JSON files 6 min read
    7. Part 18 Write a file 7 min read
    8. Part 19 Get the current working directory 4 min read
    9. Part 20 Get the script's own directory path 5 min read
    10. Part 21 Check if a path is a subdirectory of another 6 min read
    11. Part 22 Parse CSV data 6 min read
  4. 4 Async Patterns (callbacks, promises, async/await) 9 lessons · ~1h 1m
    1. Part 23 forEach in Node.js 6 min read
    2. Part 24 Loop through an array 6 min read
    3. Part 25 Async for loop in Node.js 7 min read
    4. Part 26 Async while loop 7 min read
    5. Part 27 Wait for a loop to finish before continuing 4 min read
    6. Part 28 Is Node.js single-threaded? 6 min read
    7. Part 29 Multithreading with worker threads 7 min read
    8. Part 30 Sleep / delay in Node.js 12 min read
    9. Part 31 Create a 10-second timer 6 min read
  5. 5 HTTP, HTTPS and Networking 4 lessons · ~21 min
    1. Part 32 HTTP GET request in Node.js 5 min read
    2. Part 33 Create an HTTPS server 5 min read
    3. Part 34 Fetch and serve images 5 min read
    4. Part 35 Monitor HTTPS traffic 6 min read
  6. 6 Express and Databases 6 lessons · ~45 min
    1. Part 36 Read POST body data in Express 10 min read
    2. Part 37 Handle file uploads 7 min read
    3. Part 38 Build a CMS with Express + MongoDB 6 min read
    4. Part 39 Paginate with Mongoose 6 min read
    5. Part 40 Save form data to MySQL 6 min read
    6. Part 41 Authenticate users with Passport.js 10 min read
  7. 7 Child Processes and System 1 lesson · ~6 min
    1. Part 42 Child processes in Node.js 6 min read
  8. 8 Strings, Objects, Arrays 8 lessons · ~53 min
    1. Part 43 Base64 encode and decode 8 min read
    2. Part 44 Log a full object (no truncation) 6 min read
    3. Part 45 Map function for objects 6 min read
    4. Part 46 Update a key with a new value 4 min read
    5. Part 47 Add items to an array 4 min read
    6. Part 48 Sort a Map by value 7 min read
    7. Part 49 Generate a unique ID (UUID) 12 min read
    8. Part 50 Node.js Date constructor 6 min read
  9. 9 Error Handling, Debugging and Common Errors 6 lessons · ~43 min
    1. Part 51 Node.js error handling patterns 6 min read
    2. Part 52 try / catch / finally in Node.js 6 min read
    3. Part 53 Debugging tips and tricks 10 min read
    4. Part 54 Fix: Cannot find module 12 min read
    5. Part 55 Fix: Cannot find module 'express' 3 min read
    6. Part 56 Fix: Cannot find module 'glob' 6 min read
  10. 10 Testing and Heroku Deployment 3 lessons · ~18 min
    1. Part 57 assert module examples 6 min read
    2. Part 58 assertEquals in JavaScript 6 min read
    3. Part 59 Deploy Node.js to Heroku from scratch 6 min read
  11. 11 Working with jQuery (server-side rendering) 1 lesson · ~6 min
    1. Part 60 Use jQuery on the server side 6 min read

Hands-on labs

6 guided builds you run yourself

  1. Build a CMS with Express and MongoDB

    Put together a content management system with Express routes, MongoDB storage, EJS templates, and Bootstrap 5.

  2. Add user login with Passport.js

    Register users and authenticate them with Passport's local strategy and sessions.

  3. Serve an app over HTTPS

    Generate a certificate with OpenSSL and start an HTTPS server with Node's built-in https module.

  4. Upload, display, and save images

    Accept image uploads from a form, save them on the server, and serve them back to the browser.

  5. Save HTML form data to MySQL

    Install MySQL locally, create a table, and insert rows from an Express form handler.

  6. Deploy a Node.js app to Heroku

    Prepare a Procfile and environment variables, then push an Express and MongoDB app to Heroku.

Where to go after this course

  • Node.js API documentationThe reference for every built-in module, including the version each API was added in.
  • SQL courseWrite the queries behind your Express routes yourself instead of copying them from examples.
  • Python courseUseful when your team builds APIs with Django or FastAPI instead of Express.
  • Node.js interview questionsPractise explaining the event loop, streams, and middleware before a backend interview.

Frequently Asked Questions

Which Node.js version should I use?

Use an LTS release. Node.js 24 is the newest LTS line and Node.js 22 is still supported, while Node.js 26 is the Current release for trying new features. Node.js 20 reached end of life in March 2026. Starting with Node.js 27, the project moves to one major release a year and every major becomes LTS. The Node.js releases page shows each line's status.

Is Node.js single-threaded?

Your JavaScript runs on one main thread driven by the event loop. Node.js still uses a background thread pool for file system, DNS, and some crypto operations, so slow I/O does not block that thread. For CPU-heavy work, move the calculation into a worker thread so requests keep being served. The single-threaded lesson goes through the details.

Should I use npm or Yarn?

npm ships with Node.js, and every lesson here uses npm install. Use Yarn when a project already has a yarn.lock file, so everyone on the team resolves the same dependency versions. Mixing both package managers in one project produces two lock files that drift apart.

Should I use require() or import?

Many older Node.js examples, including some lessons here, use CommonJS require(). Node.js also supports ES modules with import, either in files ending in .mjs or in any project whose package.json sets "type": "module". Using import without either of those is what causes the Cannot use import statement outside a module error.

Is Heroku still free for the deployment lesson?

No. Heroku ended its free dynos in November 2022, so the deployment lesson needs a paid plan. The steps that matter, a Procfile, environment variables, and a start script in package.json, work in much the same way on other hosting platforms.

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with 15+ years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels across development, DevOps, networking, and security, delivering robust and efficient solutions for diverse projects.

  • Go (programming language)
  • Python (programming language)
  • DevOps
  • Computer Security
  • Cloud Computing
  • Kubernetes
  • Linux
  • Ansible (software)