this post was submitted on 15 Nov 2023
7 points (88.9% liked)

Node.js

293 readers
4 users here now

founded 2 years ago
MODERATORS
 

Since Node.js v20.6 instead of using the popular dotenv package to read your .env file and make its values available under process.env, you can now pass --env-file .env to node to achieve the same, without a dependency.

Find out more...

Here is an example of the changes needed to upgrade:

config.ts config.ts diff

package.json package.json diff

Tipp: If you deploy your app as a Docker container, don't forget to add .env to your .dockerignore file, as typically you will explicitly set your environment variables in your deployment and don't want your .env file to interfere with that.

top 1 comments
sorted by: hot top controversial new old
[โ€“] Link@programming.dev 1 points 2 years ago* (last edited 2 years ago)

Here are some possibly related communities in the instance:

Feel free to crosspost into them or post future content on this topic there if they are relevant.
I am a bot and this was performed automatically ๐Ÿค– For any issues contact Ategon.