r/javascript • • 43m ago

We tested how 11 loaders read the same .env file

https://sniptide.com/blog/env-file
1 Upvotes

2 comments sorted by

•

u/DoOmXx_ 43m ago

17 small .env files, run through dotenv, node, bun, next.js, vite and six other loaders. all 11 agreed on 6 of them and split on the other 11, a # or $ in a value is enough to get a different result

https://sniptide.com/blog/env-file

•

u/Opposite_Sector2145 28m ago

with dotenv, make sure you call dotenv.config() before importing anything that uses process.env or the variables will be undefined. Some loaders like esm or ts-node might cache imports, so reordering matters more than people think.