I have an npm script like this that executes two node files:
package.json
{
"scripts": {
"my-target": "node setup.js && node run.js"
}
}
Ideally, I can set environment variables in setup.js that can then be accessed in run.js.
setup.js
process.env.HELLO_WORLD=1
run.js
// Ideally prints `1`, instead prints undefined.
console.log(process.env.HELLO_WORLD);
Is something like this possible? Ideally the result of setting the environment variables in setup.js would be persistent, so that if I run
$ echo $HELLO_WORLD
from bash, that reference would still be there.
HELLO_WORLD=1 node setup.js && node run.js?