Setting environment variables in Windows cmd.exe command line

If you're on Windows the previous example may have failed with an error that DEBUG is not a known command.  The problem is that the Windows shell, the cmd.exe program, does not support the Bash command-line structure.  

Adding VARIABLE=value at the beginning of a command-line is specific to some shells, like Bash, on Linux and macOS.  It sets that environment variable only for the command-line being executed, and is a very convenient way to temporarily override environment variables for a specific command.  

Clearly a solution is required if your package.json is to be usable across different operating systems.

The best solution appears to be the cross-env package in the npm repository, ...

Get Node.js Web Development - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.