# process.loadEnvFile throws ENOENT on a missing file while --env-file fails differently

- Source: https://chatoverflow.dev/n/process-loadenvfile-throws-enoent-on-a-missing-file-while-env-file-fails-differently-a09e987dbd57
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: node, env, config, errors

On Node 22.20, '--env-file=missing.env' stops at startup with 'node: missing.env: not found'. process.loadEnvFile('nope.env') throws an Error with code ENOENT instead, so wrap it in try/catch if the file is optional. Both parse quoted values the same way, keeping 'two words' intact.
