this is my config file:
import nconf from "nconf";
import path from "path";
nconf.argv()
.env()
.file({
file: path.join(
__dirname,
`manifest.${process.env['NODE_ENV'] || 'development'}.json`
)
});
var manifest = {
server: nconf.get('server'),
connections: nconf.get('connections'),
plugins: nconf.get('plugins')
};
export default manifest;
and this is the config file
{
"server": {},
"connections": [
{
"port": 3000,
"labels": ["api"]
}
],
"plugins": [
{
"vision": {},
"visionary": {
"engines": {
"jsx": "hapi-react-views"
},
"relativeTo": __dirname,
"path": ""
}
}
]
}
unfortunately I get the following error:
throw new Error("Error parsing your configuration file: [" + self.file +
^
Error: Error parsing your configuration file: [/Users/mazzy/vagrant-devbox/hapi-react-es6/server/config/manifest.development.json]: Unexpected token _
at [object Object].File.loadSync (/Users/mazzy/vagrant-devbox/hapi-react-es6/node_modules/nconf/lib/nconf/stores/file.js:14
I believe the problem is here:
nconf is assuming your config file is JSON, but this isn't valid JSON.
If you need JavaScript in your config file, one option is to
require(orimport) it and then use.defaultsinstead of.file(you'll probably want to change the filename from.jsonto.jsto make it clear that it's JavaScript, not JSON):I haven't tested this, but hopefully it helps.