Node.js is a JavaScript runtime built on the V8 engine that executes JavaScript outside the browser and provides operating-system APIs for files, processes, networking, environment variables, and package loading.
In simpler words
Node runs JavaScript on the server. It gives you server-side APIs and a long-running process; npm installs packages and runs package scripts.
Nest and Express both run inside Node, so runtime, module, package, and environment behavior still matters after a framework is added.
Read package.json scripts, dependencies, and devDependencies
Use process.env without committing secrets or assuming every value exists
Runtime, process, and server-side APIs
Definition
A Node process is an operating-system process running the V8 JavaScript engine plus Node APIs such as process, fs, path, streams, timers, and networking.
In simpler words
V8 executes the language; Node adds the server toolbox and keeps the process alive while work such as an HTTP listener remains open.
A browser supplies document, window, and DOM APIs. Node instead supplies process, Buffer, file-system APIs, sockets, and server-side streams.
process.argv contains command-line arguments, process.cwd() is the current working directory, and process.env contains string-valued environment variables. Validate required configuration at startup.
A Node API normally starts one long-lived process. Uncaught exceptions and unhandled promise rejections can terminate that process.
Validate configuration before listening
const port = Number(process.env.PORT ?? 3001);
if (!Number.isInteger(port) || port <= 0) {
throw new Error('PORT must be a positive integer');
}
console.log({ cwd: process.cwd(), port });
Environment variables are strings or undefined. Convert and validate them once at application startup.
Modules, package.json, and npm
Definition
A JavaScript module exposes values through exports and consumes other modules through imports; package.json declares the package boundary, scripts, dependencies, and module conventions.
In simpler words
Split code into files with explicit imports. Let package.json describe how the app is installed, built, and started.
Modern TypeScript projects normally write ESM-style import/export and compile according to tsconfig.json. CommonJS uses require/module.exports.
dependencies are needed by the running application; devDependencies support development and build work. The lockfile records an exact resolved dependency graph.
Run repository scripts through the workspace package manager. In this monorepo, pnpm filters select an app or package without changing dependency boundaries.