AceDevHub
Beginner Node.js Interview QuestionsBeginnerPractical

Node.js · Question 14

How do you install and manage Node.js versions?

Direct answer

Use nvm (Node Version Manager) or fnm to install multiple Node versions per project — pin with .nvmrc, prefer Active LTS for production, and match CI/Docker to local version.

Teams standardize on LTS releases for stability — AceDevHub API targets a single Node LTS in Docker and documents it in package.json engines field.

  • nvm — nvm install --lts; nvm use; .nvmrc file auto-switches in project root.
  • fnm — fast Rust alternative; popular on macOS/Linux CI images.
  • Official installer — nodejs.org MSI/pkg fine for beginners; harder to juggle multiple versions.
  • engines field — "engines": { "node": ">=20" } warns when team runs wrong version.
nvm-setup.sh
# Install LTS and set default
nvm install --lts
nvm alias default 22

# Project pin (.nvmrc contains "22")
cd ace-devhub-api
nvm use

node -v   # v22.x.x
npm -v