Node.js Development Setup
Practical Node.js development setup: install Node, choose a package manager, and configure ESLint, Prettier, Husky and lint-staged for a reliable developer workflow.
Introduction
Node.js is the JavaScript runtime required for modern web development. This guide covers multiple installation methods, including the official installers, the NodeSource repository, and using NVM (Node Version Manager). It also explains common commands and recommended versions for production and development.
TL;DR
Install an LTS Node.js version (use NVM for local development). Prefer `pnpm` for monorepos and faster installs; use `nvm` or `.nvmrc` to pin project versions. Verify with `node --version` and your package manager's version.
What is Node.js?
Node.js is a JavaScript runtime built on Chrome's V8 engine. It allows you to run JavaScript on the server, use npm to manage packages, and run development tools such as ESLint, Prettier, and build systems used by frameworks like Next.js, Angular, and React.
Recommended Node.js Version
Always prefer LTS versions for production. Current recommendations:
- 20.x (LTS) — Recommended for most production projects
- 18.x (LTS) — Use for legacy projects with older dependencies
- 21.x+ — Experimental; use only for testing new features
Quick Version Check
1node --version
2 npm --versionInstallation Methods Overview
Common installation methods and trade-offs:
- Official installer — Simple, single version
- NVM — Recommended for developers; easy multiple versions and per-project switching
- NodeSource / distro packages — Good for servers and system package management
Method 1 — Official Installer (Windows & Linux)
Download the LTS installer from nodejs.org.
Windows (Installer)
Run the downloaded .msi and follow the prompts. After installation verify with:
1node --version # e.g. v20.x.x
2 npm --version # e.g. 10.x.xLinux (binary / installer)
On some distributions you can download the binary or use the official installer. Example (manual binary):
1# Download Node.js tarball (example)
2cd /tmp
3wget https://nodejs.org/dist/v20.11.0/node-v20.11.0-linux-x64.tar.xz
4
5# Extract and install (example)
6tar -xf node-v20.11.0-linux-x64.tar.xz
7sudo mv node-v20.11.0-linux-x64 /usr/local/nodejs
8sudo ln -s /usr/local/nodejs/bin/node /usr/local/bin/node
9sudo ln -s /usr/local/nodejs/bin/npm /usr/local/bin/npm
10
11# Verify
12node --version
13npm --versionMethod 2 — NodeSource (Debian/Ubuntu / RHEL/Fedora)
The NodeSource repository provides up-to-date Node.js packages for many Linux distributions. Example for Debian/Ubuntu:
1# Update
2sudo apt update
3
4# Install curl if needed
5sudo apt install -y curl
6
7# Add NodeSource setup for Node 20.x
8curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
9
10# Install Node.js
11sudo apt install -y nodejs
12
13# Verify
14node --version
15npm --versionFor Fedora/RHEL use the NodeSource RPM script:
1curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
2sudo dnf install -y nodejsMethod 3 — NVM (Recommended for Developers)
NVM (Node Version Manager) lets you install and switch between multiple Node.js versions without sudo. It is the recommended approach for local development and per-project versioning.
Install NVM (Linux / macOS)
1# Install script (recommended)
2curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
3
4# Then load nvm (example for Bash)
5export NVM_DIR="$HOME/.nvm"
6[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
7
8# Verify
9nvm --versionUsing NVM
1# List remote versions
2nvm ls-remote
3
4# Install LTS
5nvm install --lts
6
7# Use a specific version
8nvm use 20.11.0
9
10# Set default
11nvm alias default 20.11.0
12
13# Verify
14node --version
15npm --versionWindows
Use the nvm-windows project for a similar workflow on Windows. Download the installer from the project releases and follow the installer prompts.
Using .nvmrc for Project-Specific Versions
Add a .nvmrc file to your project root containing the desired Node version (for example 20.11.0 orlts/*). Use nvm use to switch to the version specified in the file.
1# .nvmrc example
220.11.0
3
4# Use the version in project
5nvm usePackage Manager Notes
npm is included with Node.js. If you prefer other package managers, install them globally after installing Node.js (for examplepnpm or yarn).
1# Install pnpm
2npm install -g pnpm
3
4# Install yarn
5npm install -g yarnTroubleshooting
- Command not found: Make sure the Node binary is on your PATH. Re-open your terminal after an installer or NVM install.
- Permissions errors: Prefer NVM to avoid sudo for global installs, or configure a user-level npm prefix.
- node-gyp build errors: Install system build tools (build-essential on Linux, or Visual Studio Build Tools on Windows).
Quick Verification Checklist
1# Check Node & npm
2node --version
3npm --version
4
5# pnpm equivalents
6pnpm --version
7
8# Test a quick script
9node -e "console.log('hello node')"
10
11# Create test project (npm)
12mkdir test-node && cd test-node
13npm init -y
14npm install lodash
15node -e "const _ = require('lodash'); console.log(_.VERSION)"
16
17# Create test project (pnpm)
18mkdir pnpm-test && cd pnpm-test
19pnpm init -y
20pnpm add lodash
21node -e "const _ = require('lodash'); console.log(_.VERSION)"Ready For Production
- Pin Node version with `.nvmrc` and document it in README
- Use a lockfile (`pnpm-lock.yaml` / `package-lock.json`)
- Add `tsc --noEmit`, `eslint`, and `prettier --check` to CI
- Run integration tests and build before release
- Ensure devs use NVM or the documented installer process