which
Like which(1) unix command. Find the first instance of an executable in the PATH.
Last updated 10 years ago by isaacs .
Repository · Bugs · Original npm · Tarball · package.json
$ npm install which 
SYNC missed versions from official npm registry.

which

Like the unix which utility.

Finds the first instance of a specified executable in the PATH environment variable. Does not cache the results, so hash -r is not needed when the PATH changes.

USAGE

const which = require('which')

// async usage
// rejects if not found
const resolved = await which('node')

// if nothrow option is used, returns null if not found
const resolvedOrNull = await which('node', { nothrow: true })

// sync usage
// throws if not found
const resolved = which.sync('node')

// if nothrow option is used, returns null if not found
const resolvedOrNull = which.sync('node', { nothrow: true })

// Pass options to override the PATH and PATHEXT environment vars.
await which('node', { path: someOtherPath, pathExt: somePathExt })

CLI USAGE

Just like the BSD which(1) binary but using node-which.

usage: node-which [-as] program ...

You can learn more about why the binary is node-which and not which here

OPTIONS

You may pass an options object as the second argument.

  • path: Use instead of the PATH environment variable.
  • pathExt: Use instead of the PATHEXT environment variable.
  • all: Return all matches, instead of just the first one. Note that this means the function returns an array of strings instead of a single string.

Current Tags

  • 5.0.0                                ...           latest (3 months ago)

34 Versions

  • 5.0.0                                ...           3 months ago
  • 4.0.0                                ...           a year ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
  • 2.0.2                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.3.1                                ...           7 years ago
  • 1.3.0                                ...           7 years ago
  • 1.2.14                                ...           8 years ago
  • 1.2.13                                ...           8 years ago
  • 1.2.12                                ...           8 years ago
  • 1.2.11                                ...           8 years ago
  • 1.2.10                                ...           9 years ago
  • 1.2.9                                ...           9 years ago
  • 1.2.8                                ...           9 years ago
  • 1.2.7                                ...           9 years ago
  • 1.2.6                                ...           9 years ago
  • 1.2.5                                ...           9 years ago
  • 1.2.4                                ...           9 years ago
  • 1.2.1                                ...           9 years ago
  • 1.2.0                                ...           9 years ago
  • 1.1.2                                ...           9 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.9                                ...           10 years ago
  • 1.0.8                                ...           10 years ago
  • 1.0.7                                ...           10 years ago
  • 1.0.6                                ...           10 years ago
  • 1.0.5                                ...           13 years ago
  • 1.0.3                                ...           13 years ago
  • 1.0.2                                ...           13 years ago
  • 1.0.1                                ...           13 years ago
  • 1.0.0                                ...           13 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE