I created a command-line app that uses a .env
file in conjunction with the dotenv
NPM module to handle API credentials. So invoking the entry point like node main.js
in the project dir works.
I'm now building a web-interface and invoking this application using the child_process
module. The problem is that the environment variables are now mismatched. The command-line app sees process.env.APIKey
as undefined
and it crashes.
Now I think this is a unix-specific issue. How can I solve this problem (specifically, invoking main.js
programmatically while retaining its own environment variables scope).