Skip to content

Commit

Permalink
Mention nodejs --env-file-if-exists in dotenv alternatives
Browse files Browse the repository at this point in the history
  • Loading branch information
kouak committed Nov 10, 2024
1 parent f56a185 commit ba112f9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/modules/dotenv.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ Modern and secure alternative by the same author. It supports encryption, and mu
[Project Page](https://github.com/dotenvx/dotenvx)
[npm](https://www.npmjs.com/package/@dotenvx/dotenvx)

### Node.js --env-file
### Node.js --env-file / --env-file-if-exists

Built into Node.js since v20.6.0. Zero dependencies, good for simple use cases.
Built into Node.js since v20.6.0 (v22.9.0 for `--env-file-if-exists`). Zero dependencies, good for simple use cases.

`--env-file` will raise an error if the env-file does not exist. For those cases, where the env-file might or might not exist, use `--env-file-if-exists`.

```bash
node --env-file=.env index.js
```

Also supported by [tsx](https://www.npmjs.com/package/tsx), [Bun](https://bun.sh/docs/runtime/env#manually-specifying-env-files), and [Deno](https://docs.deno.com/runtime/reference/env_variables/#.env-file).

[Node docs](https://nodejs.org/dist/latest-v20.x/docs/api/cli.html#--env-fileconfig)
Node docs: [`--env-file`](https://nodejs.org/dist/latest-v20.x/docs/api/cli.html#--env-fileconfig) / [`--env-file-if-exists`](https://nodejs.org/docs/latest-v22.x/api/cli.html#--env-file-if-existsconfig)

0 comments on commit ba112f9

Please sign in to comment.