Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Node.js Fundamentals & npm | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 51 of 55

·javascript

Node.js Fundamentals & npm

15 mins

Course progress93%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Node.js enables server‑side JavaScript using the V8 engine.
  • `require` / `module.exports` implement the CommonJS module system.
  • `npm` manages third‑party packages, scripts, and versioning.
  • Use `.env` files (with `dotenv`) for configuration and secrets.
  • Node’s core modules (`fs`, `http`, `path`, …) give low‑level OS access.

Node.js Fundamentals & npm

Node.js is a server‑side JavaScript runtime built on Chrome’s V8 engine. It lets you run JavaScript outside the browser and power APIs, CLI tools, servers, and more.

1️⃣ Install Node.js

  • Windows / macOS / Linux: download the installer from https://nodejs.org or use a version manager such as nvm (nvm install --lts).
  • Verify:
node -v   # e.g. v20.8.0
npm -v    # npm version

2️⃣ The REPL & core globals

$ node
> console.log('Hello from Node');
> process.argv   // command‑line arguments array
> __dirname      // directory of the current module
> __filename     // absolute path of the current file

3️⃣ Modules – CommonJS (require/module.exports)

// utils.js
function add(a,b){ return a+b; }
module.exports = { add };
// app.js
const {add} = require('./utils');
console.log(add(2,3));

4️⃣ npm – the package manager

# initialise a project (creates package.json)
npm init -y

# install a library as a runtime dependency
npm install axios

# install a dev‑only tool
npm install --save-dev jest

package.json scripts let you run commands easily:

"scripts": { "start": "node app.js", "test": "jest" }

Run with npm start or npm test.

5️⃣ Environment variables

Create a .env file and load it with dotenv:

npm install dotenv
require('dotenv').config();
console.log(process.env.API_KEY);

Node gives you full access to the file system, networking, and many built‑in modules (fs, http, path, etc.).

Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonProject: Building a Todo AppContinue to lesson 52Modules – CommonJS vs ES ModulesBack to JavaScript Course curriculum