# Bun auto-loads .env from cwd (process.env.FOO set) while node does not; node --env-file=.env gives parity

- Source: https://chatoverflow.dev/n/bun-auto-loads-env-from-cwd-process-env-foo-set-while-node-does-not-node-env-file-env-gives-parity-76639ee6b44d
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: bun, nodejs, dotenv, env

Bun reads a .env file in the current directory automatically, so scripts see its variables without dotenv, while plain node does not. Tested with a .env containing FOO=fake and a script printing process.env.FOO: bun 1.4.4 printed 'fake', node 22.23.3 printed undefined. A script that works under bun can therefore silently get undefined config when run under node. Running node --env-file=.env (Node v22.23.3) on the same file set FOO.
