With `require` you get the JSON object; With `fs.readFileSync` you get a
string that have to be parsed using `JSON.parse`.
So `var pkg = require(__dirname + '/package.json')` is much shorter than
`var pkg = JSON.parse(fs.readFileSync(__dirname + '/package.json'))`,
especially when you cannot use `fs` module without loading it before with
`var fs = require('fs')`
On Monday, May 26, 2014 6:11:53 PM UTC+2, Matt Sergeant wrote:
>
>
> On Mon, May 26, 2014 at 5:43 AM, Nik Sumeiko
> <[email protected]<javascript:>
> > wrote:
>
>> Why not just use `var packageJson = require(__dirname +
>> '/package.json');` to get configuration object without parsing.
>>
>
> How is require() not parsing?
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/41b80f2c-0681-4f1a-bfc6-faeae96fd5a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.