Why not just use `var packageJson = require(__dirname + '/package.json');` 
to get configuration object without parsing.


On Monday, July 18, 2011 2:56:21 PM UTC+2, Chris Dew wrote:
>
> I have a module which needs to refer to it's own version number (and 
> other details) from within its code (for a welcome banner). 
>
> I am currently using: 
>
> var packageJson = JSON.parse(fs.readFileSync('./package.json')); 
>
> This will break once this package is required by another. 
>
> Is there a common solution for this? 
>
> Thanks, 
>
> Chris.

-- 
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/45957c2f-82de-4062-965b-cb06dd154697%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to