Documentation

Install

Install dotenvx where you need it.

npm install @dotenvx/dotenvx --save
npx dotenvx help

Npm

dotenvx is made with javascript – so you can use it just like you use dotenv – as a drop-in replacement.

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

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

Find the @dotenvx/dotenvx package here.

Brew

Installing with brew is the most straight forward global install:

# install with Homebrew and then use the dotenvx command
brew install dotenvx/brew/dotenvx

Find the dotenvx brew tap here.

Shell

After brew our install.sh script is easiest. With curl:

curl -sfS https://dotenvx.sh | sh

Or with wget:

wget -qO- https://dotenvx.sh | sh

Read the install.sh script here.

Docker

We also provide a docker image for your convenience:

docker run -it --rm -v $(pwd):/app dotenv/dotenvx help
docker run -it --rm -v $(pwd):/app dotenv/dotenvx run -- node index.js

Or in any image:

FROM node:latest
RUN echo "HELLO=World" > .env && echo "console.log('Hello ' + process.env.HELLO)" > index.js
RUN curl -sfS https://dotenvx.sh/install.sh | sh
CMD ["dotenvx", "run", "--", "echo", "Hello $HELLO"]

GitHub Releases

You can also download straight from GitHub Releases.

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

Windows

Install with winget

winget install dotenvx

or ownload the windows executable directly from the releases page.

(unzip to extract dotenvx.exe)

Other

Heroku Buildpack

For our Heroku friends, we have a heroku buildpack.

heroku buildpacks:add https://github.com/dotenvx/heroku-buildpack-dotenvx

The dotenvx binary will be available to your deployment so that you can use it in your Procfile like so.

# Procfile
web: dotenvx run -- node index.js

Standalone

dotenvx is a standalone binary, so (if you want) you can just download it directly:

# download it to `./dotenvx`
curl -sfS --proto '=https' https://dotenvx.sh/$(uname)/$(uname -m).tgz | tar xz

# install it to `/usr/local/bin/dotenvx`
sudo install -m 755 dotenvx /usr/local/bin

# check it works
dotenvx help

Download a specific version:

# download version 0.6.9
curl -sfS --proto '=https' "https://dotenvx.sh/$(uname)/$(uname -m).tgz?version=v0.6.9" | tar xz

# check the version
./dotenvx --version

Npm local

Use dotenvx locally as a cli in your node project.

npm i @dotenvx/dotenvx --save
{
  "scripts": {
    "start": "./node_modules/.bin/dotenvx run -- node index.js"
  },
  "dependencies": {
    "@dotenvx/dotenvx": "^0.6.0"
  }
}

Npm global

You can also install globally using npm's --global flag.

npm install @dotenvx/dotenvx --global
dotenvx help

Npx

Or prefer to run as needed, uses npx.

npx @dotenvx/dotenvx help

pkgx

pkgx is a single, standalone binary that can run anything. Since it can run anything, it can run dotenvx:

pkgx npx @dotenvx/dotenvx help