Skip to content

Commit c72d32d

Browse files
gaspar09ijjk
andauthored
Clarify .env* environment variable priority (#36967)
Clarify that the environment variables are ordered in descending priority and that the existing system environment is not overridden. fixes #36966 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Co-authored-by: JJ Kasper <[email protected]>
1 parent f1babe9 commit c72d32d

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

docs/basic-features/environment-variables.md

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,14 @@ export default async () => {
152152
153153
## Environment Variable Load Order
154154
155-
Depending on the environment (as set by `NODE_ENV`), Environment Variables are loaded from the following sources in top-to-bottom order. In all environments, the existing `env` is not overridden by following sources:
155+
Environment variables are looked up in the following places, in order, stopping once the variable is found.
156156
157-
`NODE_ENV=production`
158-
159-
1. `.env.production.local`
160-
1. `.env.local`
161-
1. `.env.production`
162-
1. `.env`
163-
164-
`NODE_ENV=development`
165-
166-
1. `.env.development.local`
167-
1. `.env.local`
168-
1. `.env.development`
157+
1. `process.env`
158+
1. `.env.$(NODE_ENV).local`
159+
1. `.env.local` (Not checked when `NODE_ENV` is `test`.)
160+
1. `.env.$(NODE_ENV)`
169161
1. `.env`
170162
171-
`NODE_ENV=test`
172-
173-
1. `.env.test.local`
174-
1. `.env.test`
175-
1. `.env`
163+
For example, if `NODE_ENV` is `development` and you define a variable in both `.env.development.local` and `.env`, the value in `.env.development.local` will be used.
176164
177-
> **Note:** `.env.local` is not loaded when `NODE_ENV=test`.
165+
> **Note:** The allowed values for `NODE_ENV` are `production`, `development` and `test`.

0 commit comments

Comments
 (0)