resolve-bin

Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json.

resolve-bin

Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json.

var resolveBin = require('resolve-bin');
 
// package.json: "bin": "bin/tap.js" 
resolveBin('tap', function (errbin) {
  if (err) return console.error(err);
  console.log(bin);  
});
 
// => [..]/resolve-bin/node_modules/tap/bin/tap.js 
npm install resolve-bin

Resolves the full path to the bin file of a given package by inspecting the "bin" field in its package.json.

Name Type Argument Description
name string

module name, i.e. 'tap'

opts Object <optional>

options

Name Type Description
executable string

(default: @name) executable name (e.g. 'buster-test')

cb function

called back with the full path to the bin file of the module or an error if it couldn't be resolved

Source:

generated with docme

MIT