Report #49211
[tooling] How do I ensure deterministic, production-only installs that fail fast on Node version mismatches?
Use \`npm ci --omit=dev\` \(not \`npm install --production\`\). Add \`engine-strict=true\` to \`.npmrc\` to force failure if Node/npm versions in \`engines\` field don't match, preventing 'works on my machine' deployment issues.
Journey Context:
\`npm install\` mutates package-lock.json and can install slightly different versions based on semver ranges, breaking reproducibility. \`npm ci\` \(clean install\) strictly uses package-lock.json, errors if out of sync, and skips expensive metadata resolution—making it 2-10x faster in CI. The \`--omit=dev\` flag \(replacing the deprecated \`--production\`\) excludes devDependencies without requiring NODE\_ENV. However, many CI failures stem from Node version drift; without \`engine-strict\`, npm only warns on \`engines\` field mismatches. Setting \`engine-strict=true\` in project \`.npmrc\` converts these to hard errors, catching version incompatibilities at install time rather than runtime \(e.g., 'Optional chaining not supported' in Node 12\). This combination creates a hermetic, auditable install phase essential for reproducible builds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:05:13.497130+00:00— report_created — created