{"_id":"npm-which","_rev":"93800","name":"npm-which","description":"Locate a program or locally installed node module's executable","dist-tags":{"latest":"3.0.1"},"maintainers":[{"name":"timoxley","email":""}],"time":{"modified":"2021-06-03T10:31:12.000Z","created":"2014-04-21T00:20:08.377Z","3.0.1":"2016-07-22T06:57:28.075Z","3.0.0":"2016-07-22T06:48:34.670Z","2.0.0":"2014-11-26T16:19:48.805Z","1.0.2":"2014-10-28T19:51:50.552Z","1.0.1":"2014-06-23T04:17:00.817Z","1.0.0":"2014-04-21T00:20:08.377Z"},"users":{"dshaw":true,"itonyyo":true,"icodeforcookies":true},"author":{"name":"Tim Oxley"},"repository":{"type":"git","url":"git+https://github.com/timoxley/npm-which.git"},"versions":{"3.0.1":{"name":"npm-which","version":"3.0.1","description":"Locate a program or locally installed node module's executable","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"node test/index.js | tap-spec"},"author":{"name":"Tim Oxley"},"license":"MIT","engines":{"node":">=4.2.0"},"dependencies":{"commander":"^2.9.0","npm-path":"^2.0.2","which":"^1.2.10"},"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.0"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/timoxley/npm-which.git"},"keywords":["npm","path","executable","run"],"bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"homepage":"https://github.com/timoxley/npm-which","gitHead":"126d363ea2147abf86975286e4be580e8188f607","_id":"npm-which@3.0.1","_shasum":"9225f26ec3a285c209cae67c3b11a6b4ab7140aa","_from":".","_npmVersion":"3.10.5","_nodeVersion":"6.2.2","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"9225f26ec3a285c209cae67c3b11a6b4ab7140aa","size":4726,"noattachment":false,"key":"/npm-which/-/npm-which-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-3.0.1.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/npm-which-3.0.1.tgz_1469170645174_0.4685639610979706"},"publish_time":1469170648075,"_cnpm_publish_time":1469170648075,"_hasShrinkwrap":false},"3.0.0":{"name":"npm-which","version":"3.0.0","description":"Locate a program or locally installed node module's executable","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"node test/index.js | tap-spec"},"author":{"name":"Tim Oxley"},"license":"MIT","engines":{"node":">=4.2.0"},"dependencies":{"commander":"^2.9.0","npm-path":"^2.0.1","which":"^1.2.10"},"devDependencies":{"tap-spec":"^4.1.1","tape":"^4.6.0"},"directories":{"test":"test"},"repository":{"type":"git","url":"git+https://github.com/timoxley/npm-which.git"},"keywords":["npm","path","executable","run"],"bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"homepage":"https://github.com/timoxley/npm-which","gitHead":"91c7aaf061f5ccd81f6562a5ebc320273b5f3a5e","_id":"npm-which@3.0.0","_shasum":"c6a36dd1d05dc5419fd990e7b8a88aa0612d8ab8","_from":".","_npmVersion":"3.10.5","_nodeVersion":"6.2.2","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"c6a36dd1d05dc5419fd990e7b8a88aa0612d8ab8","size":4721,"noattachment":false,"key":"/npm-which/-/npm-which-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-3.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/npm-which-3.0.0.tgz_1469170112003_0.6971918679773808"},"publish_time":1469170114670,"_cnpm_publish_time":1469170114670,"_hasShrinkwrap":false},"2.0.0":{"name":"npm-which","version":"2.0.0","description":"Locate a program or locally installed node module's executable","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"node test/index.js | tap-spec"},"author":{"name":"Tim Oxley"},"license":"MIT","dependencies":{"commander":"^2.2.0","npm-path":"^1.0.0","which":"^1.0.5"},"devDependencies":{"tap-spec":"^2.1.0","tape":"^3.0.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/timoxley/npm-which.git"},"keywords":["npm","path","executable","run"],"bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"homepage":"https://github.com/timoxley/npm-which","gitHead":"d386f8761c36ed5fedc55a50e14d5599f4ae4395","_id":"npm-which@2.0.0","_shasum":"0c46982160b783093661d1d01bd4496d2feabbac","_from":".","_npmVersion":"2.1.10","_nodeVersion":"0.10.33","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"0c46982160b783093661d1d01bd4496d2feabbac","size":4644,"noattachment":false,"key":"/npm-which/-/npm-which-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-2.0.0.tgz"},"publish_time":1417018788805,"_cnpm_publish_time":1417018788805,"_hasShrinkwrap":false},"1.0.2":{"name":"npm-which","version":"1.0.2","description":"Locate a program or locally installed node module's executable","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"faucet"},"author":{"name":"Tim Oxley"},"license":"MIT","dependencies":{"commander":"^2.2.0","npm-path":"^1.0.0","which":"^1.0.5"},"devDependencies":{"faucet":"0.0.1","tape":"^2.12.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/timoxley/npm-which.git"},"keywords":["npm","path","executable","run"],"bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"homepage":"https://github.com/timoxley/npm-which","gitHead":"2dc9ba83d5bd4198bd24ad483c783526d0307cfc","_id":"npm-which@1.0.2","_shasum":"132d209b7f73abfafd4f3f555fd1066d8d8ec202","_from":".","_npmVersion":"2.1.3","_nodeVersion":"0.10.32","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"132d209b7f73abfafd4f3f555fd1066d8d8ec202","size":3294,"noattachment":false,"key":"/npm-which/-/npm-which-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-1.0.2.tgz"},"publish_time":1414525910552,"_cnpm_publish_time":1414525910552,"_hasShrinkwrap":false},"1.0.1":{"name":"npm-which","version":"1.0.1","description":"Locate a program or locally installed node module's executable","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"faucet"},"author":{"name":"Tim Oxley"},"license":"MIT","dependencies":{"commander":"^2.2.0","npm-path":"^1.0.0","which":"^1.0.5"},"devDependencies":{"faucet":"0.0.1","tape":"^2.12.3"},"directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/timoxley/npm-which.git"},"keywords":["npm","path","executable","run"],"bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"homepage":"https://github.com/timoxley/npm-which","gitHead":"5fcc3292ba9a191ed983c4d5a483712b0d568812","_id":"npm-which@1.0.1","_shasum":"6b86b89c8213f96267b9332f8ac6dfa3eaf5f699","_from":".","_npmVersion":"1.4.16","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"dist":{"shasum":"6b86b89c8213f96267b9332f8ac6dfa3eaf5f699","size":3162,"noattachment":false,"key":"/npm-which/-/npm-which-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-1.0.1.tgz"},"publish_time":1403497020817,"_cnpm_publish_time":1403497020817,"_hasShrinkwrap":false},"1.0.0":{"name":"npm-which","version":"1.0.0","description":"which(1) with executables from npm modules.","main":"index.js","bin":{"npm-which":"bin/npm-which.js"},"scripts":{"test":"faucet"},"author":{"name":"Tim Oxley"},"license":"MIT","dependencies":{"commander":"^2.2.0","npm-path":"^1.0.0","which":"^1.0.5"},"devDependencies":{"faucet":"0.0.1","tape":"^2.12.3"},"_id":"npm-which@1.0.0","dist":{"shasum":"9a3740f0d59d1dad9804f4fa456917dad2fa03ee","size":2822,"noattachment":false,"key":"/npm-which/-/npm-which-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/npm-which/download/npm-which-1.0.0.tgz"},"_from":".","_npmVersion":"1.4.4","_npmUser":{"name":"timoxley","email":"secoif@gmail.com"},"maintainers":[{"name":"timoxley","email":""}],"directories":{},"publish_time":1398039608377,"_cnpm_publish_time":1398039608377,"_hasShrinkwrap":false}},"readme":"# npm-which\n\n### Locate a program or locally installed node module executable\n\n[![Build Status](https://travis-ci.org/timoxley/npm-which.svg?branch=master)](https://travis-ci.org/timoxley/npm-which)\n\nUse `npm-which` to locate executables which may be installed in the\nlocal 'node_modules/.bin', or in a parent 'node_modules/.bin' directory.\n\n`npm-which` runs in the context of an npm lifecycle script with its npm-modified PATH.\n\ni.e. if you install a module that has an executable script using npm install, that module's executable will be picked up by `npm-which` from anywhere in the ./node_modules tree.\n\n## Installation\n\n```bash\n> npm install -g npm-which\n```\n\n## Usage\n\n### Programmatic\n\n`npm-which` will find executables relative to the cwd you supply.\nThe cwd is required in order to be explicit and reduce confusion when\nthings that should be found are not.\n\n#### Asynchronous\n\n```js\nvar which = require('npm-which')(process.cwd()) // remember to supply cwd\nwhich('tape', function(err, pathToTape) {\n  if (err) return console.error(err.message)\n  console.log(pathToTape) // /Users/.../node_modules/.bin/tape\n})\n```\n\n#### Synchronous\n\n```js\nvar which = require('npm-which')(__dirname) // __dirname often good enough\nvar pathToTape = which.sync('tape')\nconsole.log(pathToTape) // /Users/.../node_modules/.bin/tape\n```\n\n#### Options\n\nBoth async and sync versions take an optional options object:\n\n* Set `options.env` if you wish to use something other than `process.env` (the default)\n* Set `options.cwd` to supply the cwd as a named argument. Mainly for semi-backwards compatibility with npm-which 1.0.0.\n\n```js\nwhich('tape', {cwd: '/some/other/path'}, function() {\n  // ...\n})\n```\n\n### Command Line\n\n```bash\n> npm-which tape\n/Users/timoxley/Projects/npm-which/node_modules/.bin/tape\n```\n\nThis is the equivalent of running an npm script with the body: `which tape`.\n\n### Example\n\n```bash\n# unless something is installed in a node_modules\n# npm-which and which(1) will have the same output:\n\n> which tape\n/usr/local/bin/tape\n\n> npm-which tape\n/usr/local/bin/tape\n\n# install tape local to current dir\n# tape includes an executable 'tape'\n> npm install tape\n> ./node_modules/.bin/tape && echo 'found'\nfound\n\n# vanilla which(1) still finds global tape\n> which tape\n/usr/local/bin/tape\n\n# npm-which finds locally installed tape :)\n> npm-which tape\n/Users/timoxley/Projects/npm-which/node_modules/.bin/tape\n```\n\n## Why\n\n#### npm is slow to boot\n\n* Shelling out to `npm bin` is very slow; it has to wait for all of npm to boot up – this often takes longer than the actual script you want to execute!\n\n#### Hard-coding paths to modules is very fragile\n\n* You can't rely on './node_modules' actually containing your module! The module may exist much higher in the directory hierarchy.\n* `npm bin` returns the location of the `./node_modules/.bin` directory, but it does not take into account being called within the context of another module, also, npm slow.\n* If the module does exist in a parent directory, then './node_modules/.bin' will be missing your module's executable.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/timoxley/npm-which","bugs":{"url":"https://github.com/timoxley/npm-which/issues"},"license":"MIT"}