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?
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?
You can add a "nodemonConfig" property to package.json with your env info. Then execute nodemon in your scripts section.
"nodemonConfig": {
"restartable": "rs",
"ignore": [
"node_modules/**/node_modules"
],
"delay": "2500",
"env": {
"NODE_ENV": "development",
"NODE_CONFIG_DIR": "./config"
}
}
I normally use the dotenv module on my projects.
We just need to create a .env file and require the dotenv module in our project:
.env file:
__DEV__="true"
your-script.js file:
require('dotenv').config();
console.log(process.env.__DEV__)
Creating .env files is normally a good option since we can prevent to commit our environment files using .gitignore
For windows: set DEV = true&&nodemon -w src --exec "babel-node src --presets es2015,stage-0"