Skip to content

Ensure Next.js is correctly respecting NODE_ENV #19046

@Timer

Description

@Timer

Next.js should unconditionally use NODE_ENV=development and NODE_ENV=production for next dev and next build respectively in the following areas:

The only way to read a "misconfigured" NODE_ENV (e.g. NODE_ENV=staging) should be in next.config.js. This is only allowed for backwards compatibility.

I believe we also have to allow it to override what Babel "env" is loaded. I don't feel strongly about this.

Next 11 should disallow all non-standard values for this and immediately exit. This behavior should be implemented by whatever PR closes this behind a future flag.


We also need to fix this message:

warn  - You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://err.sh/next.js/non-standard-node-env

Metadata

Metadata

Assignees

Labels

WebpackRelated to Webpack with Next.js.bugIssue was opened via the bug report template.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions