Reputation: 110
I want users of my module to be able to customize its behavior by specifying a custom field in package.json but can't figure out how to read it synchronously. If I wanted to read someField
out of the package.json of an app or module using my module, how would I do that?
Upvotes: 1
Views: 1012
Reputation: 4592
var pjson = require('./package.json');
console.log(pjson.yourcustomfield);
adopted from another SO question.
Upvotes: 3
Reputation: 13542
Use fs.readFileSync
node.js method of the fs module to read the file synchronously.
Upvotes: 1