A plug-in for config module to add environment variables to the config file.
Npm
npm install node-config-env-value
Yarn
yarn add node-config-env-value
default.json
{
"server":{
"hostname": "localhost",
"port": 3000
},
"string": "test",
"number": 4,
"boolean": true,
}
package.json
...
"scripts": {
"start": "server={port:4000} string=test2 number=1 boolean=false node index.js",
},
...
index.js
var config = require('node-config-env-value');
var NODE_ENV = config.get('NODE_ENV');
console.log(config)
/*
Config {
server: { hostname: 'localhost', port: 4000 },
number: 1,
boolean: false
string: 'test2'
ALLUSERSPROFILE: 'C:\\ProgramData',
APPDATA: 'C:\\Users\\User\\AppData\\Roaming',
...
}
*/