79822848

Date: 2025-11-17 22:53:11
Score: 1
Natty:
Report link

A new `process.loadEnvFile` function was (relatively) recently added to nodejs (https://nodejs.org/docs/v24.5.0/api/process.html#processloadenvfilepath)

If you can modify the script that you want to run, you can add:

process.loadEnvFile(".env");

And that will load your environment variables from the .env file into your `process.env `.

You can also create a wrapper script as mentioned by @RobC using this to load the .env file instead.

Even easier, more recent and also safer (according to the severe security warnings I got from installing dotenv in npm) than the dotenv package. :)

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @RobC
  • Low reputation (1):
Posted by: Jerem2360