1

I am writing a commanderjs app, that uses dotenv. The app is that is compiled using pkg .

I have compiled the app for linux and moved the binary to /usr/local/bin, for it to be available on my PATH.

I am running the app from a shell script in ~/testing/myscript.sh

When I run the script from e.g. ~/testing where does the compiled app read the .env file from?

StuperUser
  • 10,555
  • 13
  • 78
  • 137

1 Answers1

1

It reads the .env from the executing directory, in this case ~/testing/.env

This was originally failing because I had named the file myapp.env, the file must be called .env.

Alternatively, the config path can be set using a path in a object passed to .config():

dotenv.config({path:'myapp.env'});
StuperUser
  • 10,555
  • 13
  • 78
  • 137