Install
Install `dotenvx` and `dotenvx-ops`.
cURL
$ curl -sfS https://dotenvx.sh | sh
◈ installed (dotenvx)more install options
NPM
dotenvx is made with javascript – so use it just like dotenv – as a drop-in replacement.
$ npm install @dotenvx/dotenvx// index.js
require('@dotenvx/dotenvx').config()
// or import '@dotenvx/dotenvx/config' if you're using esm
console.log(`Hello ${process.env.HELLO}`)
Windows
$ winget install dotenvxreleases • amd64 • x86_64 • unzip to extract dotenvx.exe
Other
Other ways to install.
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.
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
If you download manually you'll need to move the binary somewhere in your PATH.
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
You can view available versions at github.com/dotenvx/releases
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": "^1.48.4"
}
}
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
Wget
wget -qO- https://dotenvx.sh | sh