Home

Awesome

dotenvx

a better dotenv–from the creator of dotenv.

Β 

Quickstart npm version downloads test suite

Install and use it in code just like dotenv.

npm install @dotenvx/dotenvx --save
// index.js
require('@dotenvx/dotenvx').config()

console.log(`Hello ${process.env.HELLO}`)

Β 

or install globally - unlocks dotenv for any language, framework, or platform!

<details><summary>with curl 🌐 </summary><br>
curl -sfS https://dotenvx.sh | sh
dotenvx help

curl installs

Β 

</details> <details><summary>with brew 🍺</summary><br>
brew install dotenvx/brew/dotenvx
dotenvx help

brew installs

Β 

</details> <details><summary>with docker 🐳</summary><br>
docker run -it --rm -v $(pwd):/app dotenv/dotenvx help

docker pulls

Β 

</details> <details><summary>with github releases πŸ™</summary><br>
curl -L -o dotenvx.tar.gz "https://github.com/dotenvx/dotenvx/releases/latest/download/dotenvx-$(uname -s)-$(uname -m).tar.gz"
tar -xzf dotenvx.tar.gz
./dotenvx help

github releases

Β 

</details> <details><summary>or with windows 🟦🟩πŸŸ₯🟨</summary><br>
winget install dotenvx
dotenvx help
</details>

Β 

Run Anywhere

$ echo "HELLO=World" > .env
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js

$ node index.js
Hello undefined # without dotenvx

$ dotenvx run -- node index.js
Hello World # with dotenvx
> :-D

see extended quickstart guide

More examples

Β 

Multiple Environments

Create a .env.production file and use -f to load it. It's straightforward, yet flexible.

$ echo "HELLO=production" > .env.production
$ echo "console.log('Hello ' + process.env.HELLO)" > index.js

$ dotenvx run -f .env.production -- node index.js
[dotenvx][info] loading env (1) from .env.production
Hello production
> ^^

More examples

Β 

Encryption

Add encryption to your .env files with a single command. Use dotenvx encrypt.

$ dotenvx encrypt
βœ” encrypted (.env)

encrypted .env

A DOTENV_PUBLIC_KEY (encryption key) and a DOTENV_PRIVATE_KEY (decryption key) are generated using the same public-key cryptography as Bitcoin.

More examples

Β 

Advanced

Become a dotenvx power user.

Extensions πŸ”Œ

Β 

Guides

Go deeper into using dotenvx with detailed framework and platform guides.

Β 

FAQ

Why am I getting the error node: .env: not found?

You are using Node 20 or greater and it adds a differing implementation of --env-file flag support. Rather than warn on a missing .env file (like dotenv has historically done), it raises an error: node: .env: not found.

This fix is easy. Replace --env-file with -f.

# from this:
./node_modules/.bin/dotenvx run --env-file .env -- yourcommand
# to this:
./node_modules/.bin/dotenvx run -f .env -- yourcommand

more context

What happened to the .env.vault file?

I've decided we should sunset it as a technological solution to this.

The .env.vault file got us far, but it had limitations such as:

That said, the .env.vault tooling will still stick around for at least 1 year under dotenvx vault parent command. I'm still using it in projects as are many thousands of other people.

How do I migrate my .env.vault file(s) to encrypted .env files?

Run $ dotenvx vault migrate and follow the instructions.

Β 

Contributing

You can fork this repo and create pull requests or if you have questions or feedback: