A · Foundations → Module 01
Module 01 · Questions 1–8

Node.js Fundamentals

What Node actually is, and the files every Node project has. Short module — but these are the warm-up questions, so the answers should come out cleanly.

Q1

What is Node.js?

In one line

A program that lets you run JavaScript outside the browser — so you can build servers, APIs and tools with it.

Before Node, JavaScript only ran inside a web page. Node took Chrome's JavaScript engine, put it in a normal program, and added the things a server needs: files, network, timers. Now the same language works on both sides.

Browser Node.js ┌──────────────┐ ┌──────────────┐ │ JavaScript │ │ JavaScript │ ├──────────────┤ ├──────────────┤ │ V8 engine │ │ V8 engine │ ├──────────────┤ ├──────────────┤ │ DOM, window, │ │ files, http, │ │ fetch, alert │ │ process, os │ └──────────────┘ └──────────────┘ same language, different things around it
What Node is good atWhat it's bad at
APIs that mostly wait on a database or another serviceHeavy calculations, image or video processing
Real-time features — chat, live updatesAnything that needs real multi-threading with shared memory
Tools and scriptsVery large, rule-heavy domain models (C# is stronger there)
30-second interview answer

Node.js is a JavaScript runtime built on Google's V8 engine. It lets JavaScript run outside the browser, so you can write servers and APIs with it. It runs your code on a single thread with an event loop and non-blocking I/O, which makes it very efficient for work that mostly waits — database calls, API calls, file streaming — and weak for CPU-heavy work.

Q2Is Node a runtime, a framework, or a language?

A runtime. This is a very common trick question, and the clean way to answer it is with the comparison to .NET:

JavaScript world.NET world
LanguageJavaScriptC#
RuntimeNode.js.NET / CLR
FrameworkExpress, NestJSASP.NET Core

So "I built it in Node" really means: JavaScript, running on Node, usually with Express on top.

Q3What is the V8 engine?

Google's JavaScript engine, the same one inside Chrome. Its job is to take your JavaScript text and turn it into machine code the CPU can run — quickly.

V8 doesParsing, compiling and running JavaScript; memory and garbage collection
Node addsFiles, network, processes, timers — everything V8 alone can't do

V8 is written in C++ and compiles JavaScript as it runs (JIT), which is why modern JavaScript is far faster than people expect.

Q4What is npm?

Node's package manager. It's two things with one name: the command that installs libraries, and the registry (npmjs.com) they come from. It's NuGet for Node.

npm init -y                 # create package.json
npm install express         # add a package (saved into package.json)
npm install --save-dev jest # a package only needed while developing
npm install                 # install everything package.json lists
npm run dev                 # run a script you defined
npm audit                   # check installed packages for known vulnerabilities
Q5

What is package.json?

In one line

The identity card of your project — its name, how to start it, and every package it needs.

{
  "name": "orders-api",
  "version": "1.0.0",
  "main": "src/server.js",
  "type": "module",                    // use import/export instead of require
  "scripts": {
    "start": "node src/server.js",     // npm start
    "dev":   "nodemon src/server.js",  // npm run dev — restarts on save
    "test":  "jest"                    // npm test
  },
  "dependencies": {                    // needed to RUN the app
    "express": "^4.19.2",
    "jsonwebtoken": "^9.0.2",
    "mssql": "^10.0.2"
  },
  "devDependencies": {                 // needed only while developing
    "nodemon": "^3.1.0",
    "jest": "^29.7.0"
  }
}
FieldWhat it's for
scriptsNamed commands — the team's agreed way to start, test and build
dependenciesPackages the running app needs
devDependenciesTools only developers need; left out in production
type"module" = ES Modules, otherwise CommonJS
Version symbols

^4.19.2 allows 4.x updates (not 5.0) · ~4.19.2 allows only 4.19.x · 4.19.2 means exactly that version. The ^ is the default and is why two people can install the same project and get slightly different versions — which is exactly what the lock file fixes.

Q6What are node_modules and package-lock.json?
node_modulespackage-lock.json
WhatThe folder with the actual downloaded package codeA record of the exact version of every package installed
SizeHuge — often hundreds of MBOne file
Commit it?No — put it in .gitignoreYes, always
Safe to delete?Yes — npm install rebuilds itNo

Why the lock file matters: package.json says "Express 4.x", which could install 4.19 today and 4.21 next month. The lock file pins exactly what worked. Use npm ci on build servers — it installs the lock file exactly and fails if it disagrees with package.json.

Q7node app.js vs npm start
node app.jsRuns that one file directly. Fine for a quick test.
npm startRuns whatever you wrote under scripts.start — which might set variables, use a different entry file, or add flags.

Use npm start in real projects: the command lives in package.json, so everyone (and the deployment pipeline) starts the app the same way. In development, npm run dev usually runs nodemon, which restarts the server every time you save a file.

Q8

What does a Node project look like?

orders-api/ ├─ package.json name, scripts, dependencies ├─ package-lock.json exact versions (commit this) ├─ .env local settings (NEVER commit) ├─ .gitignore node_modules, .env ├─ node_modules/ downloaded packages (never commit) └─ src/ ├─ server.js starts listening on a port ├─ app.js builds the Express app and exports it ├─ config.js reads and checks environment variables ├─ routes/ which URL goes where ├─ controllers/ handle the request and response ├─ services/ the business rules ├─ repositories/ database queries └─ middleware/ auth, validation, error handler

Two small decisions in there matter more than they look:

server.js separate from app.jsapp.js builds the app and exports it; server.js is the only file that calls listen(). Tests can then import the app without opening a port.
One folder per layerYou always know where a piece of code belongs, and a new developer can find anything in seconds.
If asked "how do you start a new Node project?"

npm init -y, install Express, create that folder structure, add start and dev scripts, add a .env with a .env.example beside it, and set up the error-handling middleware before writing the first route. Module 09 covers the layers in detail.