Node.js Now Natively Supports .env Loading and Auto-Restart Watching

Recent versions of Node.js have introduced built-in features that reduce the need for popular third-party packages. Since version 20.6, Node.js supports loading environment variables directly from .env files using the --env-file flag, eliminating the need for the dotenv package. Starting with Node.js 22, the --watch flag became stable, enabling automatic application restarts on file changes without nodemon. Developers can now run a single command combining both flags to replicate what previously required two separate dependencies. These additions are documented in the official Node.js CLI documentation.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in