CLI Usage
Once installed, use the following command structure to run the Command Line Interface:
dotenv-subst [options] <source...>
./node_modules/.bin/dotenv-subst [options] <source...>
npx dotenv-subst [options] <source...>
Each positional argument is interpreted as the path (absolute or relative to the current working directory) to a source file containing variable placeholders for interpolation.
All available command options and flags are documented in CLI Options Reference.
The CLI can also be run using the dotenvsubst
command, which is registered as bin alias in the distributed npm package.
Basic Example
With these files in your working directory:
📄 ./.env.test
USERNAME=jaydoe
GREETING=Hello
📄 ./my-test-file.md
{{GREETING}}, my name is ${USERNAME}.
Running the following command:
dotenv-subst --env-file=.env.test my-test-file.md
Updates the file with the interpolated content:
📄 ./my-test-file.md
Hello, my name is jaydoe.
🔍 Further Reading
For a comprehensive list of usage examples, head over to the CLI Examples section.
Check out the supported syntax for defining interpolation variables in your source files.