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 ext vault migrate and follow the instructions.

ย 

Contributing

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