Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): explain NODE_ENV environment variable #52003

Merged
merged 3 commits into from
Jun 29, 2023

Conversation

styfle
Copy link
Member

@styfle styfle commented Jun 29, 2023

This PR documents the NODE_ENV environment variable behavior.

This feature was originally added in 152c2c2 which was released in next@5.

See the current source code here:

const defaultEnv = command === 'dev' ? 'development' : 'production'

@@ -168,3 +168,4 @@ For example, if `NODE_ENV` is `development` and you define a variable in both `.
## Good to know

- If you are using a [`/src` directory](/docs/app/building-your-application/configuring/src-directory), `.env.*` files should remain in the root of your project.
- The environment variable `NODE_ENV` is automatically assigned to `development` when running `next dev`. All other commands automatically assign `NODE_ENV` to `production`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't override test if set x-ref:

const standardEnv = ['production', 'development', 'test']

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we don't override at all. We just have defaults.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ijjk Updated in ce2933f

@styfle styfle requested a review from ijjk June 29, 2023 20:55
@ijjk ijjk merged commit efdc026 into canary Jun 29, 2023
@ijjk ijjk deleted the docs-good-to-know-node-env branch June 29, 2023 21:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Next.js team PRs by the Next.js team. locked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants