Pro Tip — Developing on Windows: Setting variables in your script command
Recently while working on an older node project on windows, I discovered my NODE_ENV variable was coming up as ‘undefined. Turns out npm uses cmd by default and that doesn’t support command substitution. Within my project, the node module “cross-env” was updating the process.env variable(s) and the offered solution was to update the .npmrc script-shell to PowerShell. Personally, I wanted to avoid this since that would mean I or anyone else who wants to work on the repo from a non-windows OS, they’d have to maintain a .npmrc file of their own.
The Fix
Add a windows specific script command that uses “set” instead of “cross-env” (also removing the space before the ‘&&’ if doing more than one command).