Read in a settings file and evaluate in node.js

What is the best way in Node.js to read in a setting file settings.conf formatted as a JavaScript object like:

  {
     PORT: 443,
     USERNAME: "foo",
     PASSWORD: "bar"
  }

And expose those as global variables to the running application. The reading piece is easy with:

 var settings = fs.readFileSync('settings.conf');

Do I just eval(settings) or what is the best way? Thanks.

Instead of eval, use JSON.parse:

var settings = JSON.parse(fs.readFileSync('settings.conf'));

I assume that settings.conf is supposed to be JSON, to make it valid, the keys must be wrapped in double quotes:

{
    "PORT": 443,
    "USERNAME": "foo",
    "PASSWORD": "bar"
}