I have installed git-bash to be able to set env vars like that <VAR>=<value> node ...
, but now it's working only if I run node. If I do it through npm start ("start": "ENV=development node server.js"
), ENV would not be set. That's strange.
But if I do ENV=development npm start
or ENV=development node server.js
, it sets.
Where could the problem be?
P.S. I run bash through typing bash
in powershell (I tried to do bash selectable in visual code terminal, even though I added ../git/bin/ to the PATH I still don't see it).
"start": "env ENV=development node server.js"
(note the initial env prefix). Alternatively for cross-platform utilize the cross-env package.npm i -D cross-env
. 2) Redefining your npm script as"start": "cross-env ENV=development node server.js"
- that should work for both Windows and Linux.