module-info

Find package.json files in module and load information from it

module-info

Find package.json files in module and load information from it.

$ npm install module-info

Base option is to set base directory of module.

var Info = require('module-info');
var info = new Info('/path/to/some/module');

If you have got some file somewhere in module directory tree, module-info can find information about module automatically.

var info = Info.fromFile('/path/to/some/module/and/some/file/in/it.js');

You can search for information about some module on which your module is dependent.

var info = Info.fromName(module, 'dependent-module');

This option is similar for example to package pkginfo.

var info = Info.self(module);
  • getPackagePath(): returns path to package.json file
  • getPackageData(): returns parsed JSON data from package.json file
  • getName(): returns name of module
  • getVersion(): returns version of module
  • getMainFile(): returns resolved full path to main file (even it is not defined in package.json)
$ npm test
  • 1.0.0
    • First version