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:
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.
- Author: Ahmed Bouchefra Follow @ahmedbouchefra
-
Date:
Related posts
Angular 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 16Hands-on Angular eBook
Subscribe to our Angular newsletter and get our hands-on Angular book for free!