node --env-file replaces dotenv
Loading a .env file does not need a package any more. Node reads it before your code runs, so there is no import to keep at the top of the entry file.
node --env-file=.env server.js
node --env-file-if-exists=.env.local --import tsx scripts/sync.ts--env-file landed in 20.6 and --env-file-if-exists in 22.9, and the second one is what you want for an optional local override, since a missing file is not an error. It reads KEY=value and quoted values, with no expansion of $OTHER, so keep those references out of the file.
nodejstooling