Skip to content
Discussion options

You must be logged in to vote

process.env.NODE_ENV returns the NODE_ENV environmental variable and if you don't set it it will return undefined. This is something managed by Node.js and your OS. app.get('env') returns the app setting called 'env', which is set to the value of process.env.NODE_ENV or 'development' if that variable does not exist or is empty.

app.defaultConfiguration = function defaultConfiguration() {
var env = process.env.NODE_ENV || 'development';
// default settings
this.enable('x-powered-by');
this.set('etag', 'weak');
this.set('env', env);

Express won't override the environmental variable if it is …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@WaningJupiter
Comment options

Answer selected by WaningJupiter
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants
Converted from issue

This discussion was converted from issue #7523 on October 16, 2026 17:04.