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.

  • Link@programming.devB
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year 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.