I have a file (.env) of environment variables defined at the root of my NPM module which looks like this:
FOO=bar
BAZ=zoo
I would like to have these variables made available when I run the module's package.json scripts.
Here's an attempt from my package.json:
{
...
"scripts": {
"foo": "source ./.env && echo $FOO"
}
...
}
But, when I run npm run foo I get this error:
sh: 1: source: not found
How can I make $FOO available in this context?
A cross-OS solution would best, but for now I'm running on Ubuntu.
scriptssection. In my case, I'm not trying to run a node.js program...just a bash script