Skip to content

[6.x] Default "env" to production and stop reading NODE_ENV - #7549

Open
UlisesGascon wants to merge 1 commit into
masterfrom
ulises/6x-env-production-default
Open

UlisesGascon wants to merge 1 commit into
masterfrom
ulises/6x-env-production-default

Conversation

@UlisesGascon

Copy link
Copy Markdown
Member

⚠️ Breaking changes

  • The env setting is no longer derived from NODE_ENV and now defaults to production, so the safe behavior is the default: the default error handler never includes error details in responses and view cache is enabled. Set app.set('env', 'development') to get the previous development behavior, or set view cache directly

    const app = express();
    app.get('env'); // => 'production', regardless of NODE_ENV
    app.set('env', 'development'); // opt in to error details in responses
    app.set('view cache', false); // opt out of template caching

Notes for reviewers

  • The test suite previously relied on NODE_ENV=test. test/support/env.js now defaults every app to env: test by wrapping defaultConfiguration, which keeps error details in test responses and the default logger quiet. Explicit app.set('env', 'test') calls in the affected tests would be the alternative.
  • Exploratory PR for the 6.x line, parked until the major is consolidated.

BREAKING CHANGE: the "env" setting no longer derives from NODE_ENV and
defaults to "production". The default error handler never exposes error
details and "view cache" is enabled unless the app opts into development
with app.set('env', 'development').
@UlisesGascon UlisesGascon added 6.x semver-major This change is a semver major labels Oct 23, 2026
@UlisesGascon UlisesGascon self-assigned this Oct 23, 2026
@UlisesGascon

Copy link
Copy Markdown
Member Author

If we agree on this approach... then I can prepare a deprecation warning for express@5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.x semver-major This change is a semver major

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant