NODE_ENV
An environment variable, usually set to production or development, that libraries, frameworks and build tools read to switch behaviour.
In more detail
Node.js itself ignores it; frameworks such as Express use it to switch off debugging output and switch on caching. Bundlers replace process.env.NODE_ENV with a literal value, so development-only code such as extra warnings is stripped from production bundles. Keep it the same in every deployed environment so tests behave like production.
Related terms
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- deprecation warning — A message logged to the developer console when code uses a deprecated prop or component, pointing to the replacement.
- production — The live environment where real users use the service, as opposed to development or testing.
- Express — The most widely used web framework for Node.js, providing routing and middleware on top of node:http.
Taught in
- System Governance: Changesets, Semantic Versioning & Deprecation — Design Systems & Component Engineering
- Runtime Configuration: CLI Flags & Native --env-file — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services