Skip to content Skip to sidebar Skip to footer

Setting An Env Var In Package.json For Use With Electron-reload?

I usually develop on macOS but I've moved the project over to Windows 10 in order to work on some Windows-specific issues. I use electron-reload to reload the app when changes are

Solution 1:

The syntax ENV_VAR=value program arguments is a UNIX thing. Windows does not provide a way to set an environment variable and run a program in the same command, however, this will generally work: set ENV_VAR=value && program arguments (so, in your case: set APP_DEV=true && electron . is what you're looking for). As a suggestion, look at dotenv and/or cross-os to make your project more usable (in this regard) on all systems without too much headache.


Solution 2:

Have you tried moving your argument till after the electron command ("electron") and src location (".")?

APP_DEV does NOT exists:

"start": "APP_DEV=true electron ."

APP_DEV does exists:

"start": "electron . APP_DEV=true"

EDIT:

The above mentioned method would not be able to retrieve as enviromental variables, but as process arguments. Not sure if this will be able to solve your issue.

string[] argument = process.argv;

Post a Comment for "Setting An Env Var In Package.json For Use With Electron-reload?"