nodemon, babel-node: how to set environment variable?

stkvtflw picture stkvtflw · Jul 5, 2017 · Viewed 19.1k times · Source

Dev environment starts with this command:

nodemon -w src --exec \"babel-node src --presets es2015,stage-0\"

How do i create a global variable (or process.env variable) __DEV__ = true?

Answer

Oleksii Filonenko picture Oleksii Filonenko · Jul 5, 2017

You can either add "env" property to nodemon.json, like this:

...
"env": {
    "__DEV__": "true"
}

Or you can prepend __DEV__="true" to start script in package.json. Both worked for me.