I'm trying to use pkg with dotenv. I specified .env files as assets for pkg, but when I start the binary file, it throws the well known error about absolute paths.
Which is the recommended way to handle env variables in a very clean way like dotenv without breaking the binary file?
thank you.
Fixed passing the full absolute path to dotenv, instead of the file name
Hello,
I tried to put /snapshot/crawl/.env but it's not work.
is my path correct?
Can you please post the solution?
This was my solution:
const dotenvAbsolutePath = path.join(__dirname, '../.mydotenvname');
const dotenv = require('dotenv').config({
path: dotenvAbsolutePath
});
if (dotenv.error) {
throw dotenv.error;
}
Most helpful comment
This was my solution: