Node.js Environment

A clean setup saves time later. Choose one Node version, one package manager, and one editor workflow before you start serious work.

Install Node

Always prefer an Active Long-Term Support (LTS) release of Node.js for production services and shared team repositories. Using a version manager such as nvm (macOS/Linux), nvm-windows, or fnm lets you switch Node runtimes per project via an .nvmrc file without breaking older repositories.

Project basics

Every Node project starts with a package.json manifest that records its entry point, scripts, module type, and dependency lockfile. Initialize a workspace and verify both the runtime and package manager versions before installing dependencies:

mkdir node-lab
cd node-lab
npm init -y          # generates package.json with sensible defaults
node -v              # confirm Active LTS version (e.g., v22.x)
npm -v               # confirm npm CLI is available

Tools for writing Node code

Pair Node with an editor that understands JavaScript/TypeScript types and integrates with the built-in V8 inspector for breakpoints:

  • VS Code: Lightweight, fast startup, built-in terminal, and zero-config Node debugging via launch profiles or JavaScript Debug Terminal.
  • WebStorm: Full IDE with deep refactoring, dependency inspection, and integrated test runners.
  • Neovim / CLI editors: Lean terminal-first workflow paired with typescript-language-server and ESLint.
  • Git: Commit package-lock.json (or pnpm-lock.yaml) so CI and teammates install identical dependency trees.

Package manager choices

Stick to one package manager per repository so lockfiles never drift:

  • npm: Ships with Node by default and works everywhere with zero extra setup.
  • pnpm: Uses a content-addressable store to save disk space and enforces strict dependency isolation in monorepos.
  • yarn: Common in legacy and enterprise workspaces with Plug'n'Play or workspace protocols.

Practice

Verify your local Node toolchain with these quick checks:

  1. Install an LTS Node release and confirm node -v and npm -v in your terminal.
  2. Create a fresh directory, run npm init -y, and inspect the generated package.json fields.
  3. Add a "start": "node index.js" script to package.json and execute it with npm start.