Node.js v20.6.0: Introducing Built-in .env File Support

Node.js v20.6.0: Introducing Built-in .env File Support

There is no longer a need to rely on additional packages for.env file support with the release of Node.js v20.6.0. This not only decreases the application's dependencies, but also guarantees that the processing of.env files is consistent throughout the Node.js ecosystem.

To make advantage of the built-in.env support:

  • Make a .env file in the root of your project, or rename it if you wish.
  • Use the following CLI command to start your Node.js application with predefined configurations:
node --env-file=my.env index.js

For example if your env file contains the following configuration:


You can access this configuration using the following syntax:


This new modification, in along with environment variables, allows developers to declare their NODE_OPTIONSdirectly in the.env` file. This is a huge improvement because it eliminates the requirement for these settings to be included in package.json.