dotenv 18 breaking changes: what to fix when you upgrade from 17
Updated November 30, 2026
On this page
What changed in dotenv 18?
Five things can break, and three of them give you no error at all. Your require('dotenv').config() call still loads .env the same way. What changed is everything around it. The dotenv changelog lists 18.0.0 as: a new CLI, an opt-in fast parser, the log message moved to stderr with tips removed, and five removals (tips, skill files, the Spanish README, .env.vault support and preloading).
I ran each case on dotenv 17.4.2 and 18.0.10 with Node.js 24.21.0 on November 30, 2026. Here's what actually differs:
| Behavior | dotenv 17.4.2 | dotenv 18.0.10 |
|---|---|---|
node -r dotenv/config app.js | Works | Works |
dotenv_config_path=.env.local argument | Loads .env.local | Ignored, loads .env, no warning |
.env.vault with DOTENV_KEY | Decrypts the vault | Ignored, loads .env, no warning |
| The "injected env" log line | stdout, with a rotating tip | stderr, no tip |
decrypt, _configVault, _parseVault | Exported | Removed (undefined) |
dotenv/lib/* deep imports | Exported | ERR_PACKAGE_PATH_NOT_EXPORTED |
dotenv binary | None | dotenv run |
DOTENV_PATH and other DOTENV_* | Not read | DOTENV_CONFIG_* still read as fallbacks |
Upgrade straight to the latest 18.0.x, not 18.0.0. Per the changelog, the ten patch releases after it fixed real problems: 18.0.4 made dotenv/config quiet by default again (on 18.0.0 my preload printed ◇ injected env (1) from .env on every start), 18.0.5 restored a missing TypeScript module declaration, and 18.0.10 (November 8, 2026, per the changelog) fixed dotenv.parse in Vite.
Does node -r dotenv/config still work in dotenv 18?
Yes. The preload itself still runs, despite the "Remove preloading" line in the changelog. What's gone is the way you passed it options: the dotenv_config_path=, dotenv_config_override= and other dotenv_config_* arguments after your script name. dotenv 17 read them from process.argv in lib/cli-options.js, and that file doesn't exist in 18. Your app starts, finds no error, and reads the wrong file.
Same command, same folder, with HELLO=World in .env and HELLO=Local in .env.local:
# dotenv 17.4.2
$ node -r dotenv/config index.js \
dotenv_config_path=.env.local
Hello Local
# dotenv 18.0.10
$ node -r dotenv/config index.js \
dotenv_config_path=.env.local
Hello WorldThe fix is to pass the option as an environment variable instead. dotenv 18 reads DOTENV_PATH, DOTENV_QUIET, DOTENV_OVERRIDE, DOTENV_ENCODING, DOTENV_DEBUG and DOTENV_FAST, and per the dotenv README the older DOTENV_CONFIG_* names still work as fallbacks. If you want one script that runs on both 17 and 18, use the old name, because 17 ignores DOTENV_PATH:
# dotenv 18.0.10
$ DOTENV_PATH=.env.local \
node -r dotenv/config index.js
Hello Local
# dotenv 17.4.2
$ DOTENV_PATH=.env.local \
node -r dotenv/config index.js
Hello World
# both versions
$ DOTENV_CONFIG_PATH=.env.local \
node -r dotenv/config index.js
Hello LocalThe maintainer's own advice in the Dotenv 18 announcement is to switch preloads to the new CLI, dotenv run -- node index.js. I'd do that for new scripts. For existing ones, the environment variable is the one-line fix, and it's the smaller diff to review.
Why did my .env.vault stop loading after upgrading dotenv?
Because dotenv 18 removed .env.vault support entirely, and it doesn't tell you. With DOTENV_KEY set, dotenv 17 decrypted the matching DOTENV_VAULT_<ENVIRONMENT> entry. dotenv 18 ignores both the key and the vault and loads plain .env if there is one. In production, where there usually isn't, your variables are simply missing.
I built a test vault with a random key in the format dotenv 17's decrypt() reads (AES-256-GCM, the nonce first and the auth tag last), holding HELLO=Vault, next to a .env holding HELLO=World. load.js calls config() and prints HELLO. v17's tip text is cut:
# dotenv 17.4.2
$ DOTENV_KEY="$KEY" node load.js
◇ loading env from encrypted .env.vault
◇ injected env (1) from .env.vault // tip: ...
HELLO=Vault
# dotenv 18.0.10
$ DOTENV_KEY="$KEY" node load.js
◇ injected env (1) from .env
HELLO=WorldIf you still use a vault, you have two choices. Stay on dotenv 17 for now and pin it ("dotenv": "~17.4.2" keeps you on 17.4.x; see caret vs tilde). Or move the secrets out: the announcement points to dotenvx for encrypted .env files, and your platform's own secret store works too. Either way, decide before a dependency bot raises dotenv to 18 for you.
A quick guard that catches this class of failure: check the variables you need right after loading, and exit if one is missing. Then a silent change in how .env gets loaded shows up as a failed start instead of a bug report.
Why does dotenv-cli break after upgrading dotenv to 18?
Because both packages now install a binary called dotenv, and dotenv 18's wins. dotenv-cli 11.1.0 (October 28, 2026, per npm) depends on dotenv ^17.1.0, so when your project also lists dotenv 18 directly, npm puts 18 at the top level and links node_modules/.bin/dotenv to its CLI. Every script written as dotenv -e .env.test -- jest now runs a different program.
$ npm install dotenv-cli@11.1.0 dotenv@18.0.10
$ ls -la node_modules/.bin | grep dotenv
... dotenv -> ../dotenv/dist/cli.cjs
... dotenv-cli -> ../dotenv-cli/cli.js
$ npx dotenv -e .env.local -- node index.js
Usage: dotenv run [--help] [-q|--quiet] ...
$ echo $?
1I've cut the ls columns and the usage text, which goes on to list dotenv 18's own options. With dotenv 17.4.2 instead, the same npx dotenv -e command printed Hello Local, because 17 has no binary.
dotenv-cli also installs itself as dotenv-cli, and that name doesn't clash. Rename the command in your scripts and keep everything else:
$ npx dotenv-cli -e .env.local -- node index.js
Hello LocalOr drop dotenv-cli and use dotenv 18's own command: dotenv -e .env.test -- jest becomes dotenv run -f .env.test -- jest. Check the options you rely on first. dotenv-cli also pulls in dotenv-expand for variable expansion, and dotenv 18's --help lists no expansion option.
Where did dotenv's log message go in version 18?
To stderr, without the tip. dotenv 17 wrote ◇ injected env (1) from .env plus a rotating tip to stdout every time config() ran. dotenv 18 writes the same line to stderr and drops the tip. You can see it by silencing one stream at a time:
# dotenv 17.4.2: the line is on stdout
$ node load.js 2>/dev/null
◇ injected env (1) from .env // tip: ...
HELLO=World
# dotenv 18.0.10: the line is on stderr
$ node load.js 2>/dev/null
HELLO=World
$ node load.js >/dev/null
◇ injected env (1) from .envMost apps won't care. It matters if a CLI you wrote prints JSON to stdout and something parses it (17's line broke that, so 18 fixes it), or if a test or log pipeline counts on that line being on one stream. To turn it off in either version, pass config({ quiet: true }). The dotenv/config preload and import are quiet by default from 18.0.4 on; set DOTENV_QUIET=false to see the line again.
Which exports did dotenv 18 remove?
Three functions and every file under dotenv/lib. The package's main export went from seven keys to four:
# dotenv 17.4.2
$ node -e "console.log(Object.keys(
require('dotenv')).sort().join(' '))"
_configVault _parseVault config configDotenv
decrypt parse populate
# dotenv 18.0.10
config configDotenv parse populateI've wrapped the command and the 17.4.2 output to fit. Code that destructures decrypt gets undefined and fails with a TypeError only when it's called, not on import. A deep import such as require('dotenv/lib/env-options') fails at once with ERR_PACKAGE_PATH_NOT_EXPORTED, because 18's exports map only lists ., ./config, ./config.js and ./package.json. The code moved from lib/main.js to dist/index.cjs, which npm diff --diff=dotenv@17.4.2 --diff=dotenv@18.0.10 --diff-name-only shows in its file list.
config(), configDotenv(), parse() and populate() behave the same in my runs, including a missing file: config({ path: 'nope.env' }) returns an ENOENT error object on both versions instead of throwing.
How do I upgrade from dotenv 17 to 18 safely?
Search for what 18 changes, fix each hit, then bump. Start in a git repository, from the root:
$ P='dotenv_config_|dotenv -e |DOTENV_KEY'
$ P="$P|env\.vault|dotenv/lib|decrypt"
$ git grep -lE "$P"
package.json
src/secrets.jsThat's the output on a small test repository with one preload script, one dotenv-cli script and one decrypt call. Expect some noise from unrelated words like decrypt; open each file it names. Then:
- Replace
dotenv_config_path=xarguments withDOTENV_CONFIG_PATH=xin front of the command, or switch the script todotenv run -f x -- node app.js. - Rename
dotenv -escripts todotenv-cli -e, or move them todotenv run -f. - If anything sets
DOTENV_KEYor ships a.env.vault, move those secrets first, or hold dotenv at 17. - Remove calls to
decryptand imports fromdotenv/lib. - Bump with
npm install dotenv@^18.0.10, start the app once withDOTENV_QUIET=falseand check that the injected env line names the file and the count you expect.
dotenv 18 still declares "node": ">=12" in its package.json, the same as 17.4.2, so you don't need a Node.js upgrade for it. For the general method behind that search, see how to find breaking changes between two versions.
Should I use dotenv run or Node's env-file flag?
Use Node's --env-file when you only run Node and want one dependency fewer; use dotenv run when the command isn't Node, or you want dotenv's options. Per the Node.js CLI docs, --env-file was added in v20.6.0 and stopped being experimental in v24.10.0 and v22.21.0.
$ node --env-file=.env index.js
Hello World
$ npx dotenv run -f .env.local -- node index.js
◇ injected env (1) from .env.local
Hello LocalThe differences that matter: Node exits with node: nope.env: not found if the file is missing (--env-file-if-exists carries on), while dotenv run starts any executable on your PATH, per the Dotenv 18 announcement, so it works for scripts that aren't Node. Both leave a variable you already set alone (HELLO=Shell node --env-file=.env index.js printed Hello Shell); dotenv run --override lets the file win. In my run, HELLO=Shell npx dotenv run -- node index.js printed Hello Shell with injected env (0), and adding --override printed Hello World. Check which Node.js lines are still supported on the Node.js release calendar before you rely on a flag.
Where Since.dev fits
Since.dev keeps a dotenv breaking changes page that lists every dotenv release that removed or changed something, each with its source, so a line like "Remove preloading" sits next to what it means for your code. For the habit that catches changes like these before you merge a bump, see checking dependencies for breaking changes before you upgrade.
To see what a public repository is exposed to, run a free scan, or give your coding agent the same answers through the docs. When a change like dotenv 18's reaches a repository you connect, Since.dev reports where your code is affected and can open a pull request with the fix for you to review. It doesn't open routine version bumps. Nothing merges or deploys on its own.
Questions
Is dotenv 18 a breaking change?
Yes, for some projects. config() and parse() work the same, but dotenv 18 removes .env.vault decryption, the dotenv_config_* command-line arguments for preloads, the decrypt export and deep imports from dotenv/lib. It also moves its log line to stderr and adds a dotenv binary that replaces dotenv-cli's.
Does import 'dotenv/config' still work in dotenv 18?
Yes. Both import 'dotenv/config' and node -r dotenv/config still load .env on 18.0.10. From 18.0.4 they are quiet by default. To change the file, set DOTENV_PATH or DOTENV_CONFIG_PATH in the environment, since dotenv_config_path= arguments are ignored.
Why is dotenv_config_path ignored after upgrading to dotenv 18?
dotenv 18 deleted the code that read dotenv_config_* arguments from the command line. The preload still runs but falls back to .env with no warning. Use DOTENV_CONFIG_PATH=.env.local node -r dotenv/config app.js, which works on both 17 and 18.
What replaced .env.vault in dotenv 18?
Nothing inside dotenv. Version 18 removed .env.vault support, and the maintainer's announcement points to dotenvx for encrypted .env files. Until you move the secrets, keep dotenv on 17 with a range like ~17.4.2.
Why does my dotenv -e command print Usage: dotenv run after upgrading?
Because dotenv 18 installs its own dotenv binary, and npm links it ahead of the one from dotenv-cli, which still depends on dotenv 17. Call dotenv-cli -e instead of dotenv -e, or rewrite the script to use dotenv run -f with your .env file.
Do I need a newer Node.js for dotenv 18?
No. dotenv 18.0.10 declares Node.js 12 or later in the engines field of its package.json, the same as 17.4.2. If you'd rather drop the package, Node's own env-file flag has been in Node.js since v20.6.0.
Related guides
How-to
- How to find the breaking changes between two versions of a packageHow to find breaking changes between two versions of a package: list the releases in between, read each changelog, diff the code. Commands for npm, PyPI, Go.
- How to check your dependencies for breaking changes before you upgradeHow to check dependencies for breaking changes before upgrading: the commands, a real failing upgrade, CI that fails on deprecations, and where notices appear.
- boto3 1.44.0 breaking changes: the new retry default, testedboto3 1.44.0 makes standard retries the default: 3 attempts instead of 5, much shorter waits, and bearer tokens need HTTPS. Tested on both versions.
Explainers
- Caret vs tilde in package.json: what ^ and ~ let inCaret (^) allows minor and patch updates, tilde (~) only patches. The 0.x exception, what your lockfile does, and how ^ and ~ differ in Cargo and Composer.

Put your code on continuous maintenance.
Scan a public repository now, or give your agent one line.
See how out of date your code is.
Tell your agent what changed since it was trained.
claude mcp add --transport http since https://api.since.dev/mcpCodex, Cursor and any MCP client use https://api.since.dev/mcp.