npm install --save config.local
In different enviornments, projects need different config setting. Maybe most config setting is same, but sometimes always has something need special setting. For example, the database on the production config setting is different with the test enviornment or your local envoirnment. The key is the same, but the value maybe not.
let config = require("config.local");
console.log(config);
- config folder on the root director.
- config.json file in the config folder.
- config.local.json file in the config folder.
{
"name":"Simth",
"work":{
"city":"Beijing",
"company":"IT",
"hisname":"{{name}}"
}
}
{
"name":"Amy",
"work":{
"city":"NewYork",
},
"sex":"man"
}
let config = require("config.local");
console.log(config);
/*
{
"name":"Amy",
"work":{
"city":"NewYork",
"company":"IT",
"hisname":"Amy"
}
}
*/