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
.envfile 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
directly in the.env` file. This is a huge improvement because it eliminates the requirement for these settings to be included in package.json.
Related postsAngular 16 Signals - mutate & update examples Node.js v20.6.0: Introducing Built-in .env File Support Angular 16 Get Routing Parameters with @Input Angular 16 Required Input with Example Angular 16 provideRouter Example: Use Standalone Components with Angular 16 Router Add Jest Support to Angular 16 Angular 16 Inject HttpClient Angular 16 Get the Current Route Example Converting Signals to Observables in Angular 16
Hands-on Angular eBook
Subscribe to our Angular newsletter and get our hands-on Angular book for free!