Monday, September 23, 2013

The "main" specification within package.json will denote which .js file to use as the gateway to an npm package.

"main": "foo/bar"

 
 

...for example will try to find "bar.js" in the "foo" folder. The module.exports object specified in the .js file specified in main will be returned. For example:

module.exports=baz;

 
 

...will return a baz variable which might be newed up like so:

var baz = {};

 
 

...and may have functions bolted onto it like this:

baz.run = function() {
   return "qux!";
};

No comments:

Post a Comment