Loading episodes…
0:00 0:00

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

00:00
BACK TO HOME

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

10xTeam September 07, 2023 1 min read

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:

password:123456

You can access this configuration using the following syntax:

console.log(process.env.password);

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


Join the 10xdev Community

Subscribe and get 8+ free PDFs that contain detailed roadmaps with recommended learning periods for each programming language or field, along with links to free resources such as books, YouTube tutorials, and courses with certificates.

Audio Interrupted

We lost the audio stream. Retry with shorter sentences?