which
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/which package

5.0.0 • Public • Published

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.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
5.0.0
10,054,540latest

Version History

VersionDownloads (Last 7 Days)Published
5.0.0
10,054,540
4.0.0
11,708,051
3.0.1
3,598,778
3.0.0253,239
2.0.266,637,718
2.0.148,419
2.0.080
1.3.132,511,252
1.3.0355,543
1.2.14584,238
1.2.1310
1.2.1235,694
1.2.1149,834
1.2.101,374
1.2.9108
1.2.8120
1.2.712
1.2.69
1.2.58
1.2.488,402
1.2.1381
1.2.0304
1.1.2556
1.1.11,678
1.1.010
1.0.9286,756
1.0.841
1.0.715
1.0.68
1.0.53,044
1.0.37
1.0.222
1.0.123
1.0.022

Package Sidebar

Install

npm i which

Weekly Downloads

126,220,296

Version

5.0.0

License

ISC

Unpacked Size

7.48 kB

Total Files

5

Last publish

Collaborators

  • gar
  • saquibkhan
  • npm-cli-ops
  • reggi
  • hashtagchris
  • owlstronaut