Busca en todas las páginas de la documentación
Consistent Node versions across laptops, CI, and production prevent "works on my machine" failures - pin Active LTS and enforce it at install time.
Quick-reference recipe card - copy-paste ready.
// package.json
{
"engines": {
"node": ">=24.18.0 <25",
"npm": ">=10.0.0"
},
"engineStrict": true
}# .nvmrc
24.18.0When to reach for this:
# Install fnm (macOS/Linux) - fast, cross-shell version manager
curl -fsSL https://fnm.vercel.app/install | bash
fnm install 24.18.0
fnm use 24.18.0
node --version # v24.18.0// package.json excerpt
{
"name": "billing-api",
"type": "module",
"engines": { "node": ">=24.18.0 <25" },
"scripts": {
"preinstall": "node scripts/check-node-version.mjs"
}
}// scripts/check-node-version.mjs
const required = 24;
const major = Number(process.versions.node.split('.')[0]);
if (major !== required) {
console.error(`Node ${required}.x required, got ${process.version
What this demonstrates:
.nvmrc / .node-version files integrate with fnm, nvm, and asdfengines documents the supported range for humans and toolingpreinstall script fails fast before npm install downloads packages<25 excludes Current (odd-numbered) releases unsuitable for productionengines is advisory unless engine-strict=true in .npmrc or you add enforcement scripts.node:24.18.0-bookworm-slim images - not node:latest.package.json volta field and auto-switches on cd.| Tool | Speed | Pinning model | Best for |
|---|---|---|---|
| fnm | Fast (Rust) | .nvmrc, shell hook | Daily dev on macOS/Linux |
| nvm | Moderate | .nvmrc, widely known | Legacy docs and tutorials |
| Volta | Fast | package.json volta block | Teams wanting zero manual use |
| asdf | Plugin-based | .tool-versions | Polyglot repos (Node + Ruby + Go) |
// Read the runtime version at startup and expose it in /health
export function runtimeInfo(): { node: string; platform: string } {
return {
node: process.version,
platform: `${process.platform}-${process.arch}`,
node:latest in Docker - every build may get a different major version. Fix: pin node:24.18.0-bookworm-slim with a digest.engines without enforcement - npm warns but installs anyway by default. Fix: engine-strict=true in .npmrc or CI gate.npx, pnpm dlx, or project-local devDependencies.| Alternative | Use When | Don't Use When |
|---|---|---|
| Volta | Automatic per-project switching | You need Windows support with minimal setup friction |
| asdf | One tool for many languages | Node-only teams wanting the simplest path |
| Container-only (no local manager) | Devcontainers / Docker-only workflows | Fast local iteration without container overhead |
System package manager (apt, brew) | Quick one-off installs | Production parity or multi-version switching |
Node.js 24.18.0 (Active LTS) for new deployments. Node 22.23.1 (Maintenance LTS) is acceptable during migration but plan to upgrade before maintenance ends.
Both swap Node versions via shell hooks. fnm is faster (written in Rust) and supports the same .nvmrc file format.
Yes. Commit .nvmrc or .node-version so every developer and CI job resolves the same version.
Add a volta section to package.json:
"volta": { "node": "24.18.0", "npm": "10.9.0" }Volta switches automatically when you enter the project directory.
When engine-strict=true in .npmrc, npm refuses to install if the running Node/npm does not satisfy engines.
Yes. corepack enable activates the package manager version declared in packageManager field:
"packageManager": "pnpm@9.15.0"Match CI to .nvmrc:
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'fnm, nvm-windows, and Volta all support Windows. Document one canonical tool in the team README.
No for production. Odd releases are "Current" and short-lived. Use Active LTS (even numbers) for services.
npm list -g --depth=0Prefer project-local devDependencies over globals for reproducibility.
Alpine uses musl libc - some native addons need extra build steps. bookworm-slim (Debian) is safer for native modules.
Upgrade dev machines and CI first, run the test suite, check deprecated API warnings with NODE_OPTIONS=--pending-deprecation, then roll production.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.