{"_id":"which-command","name":"which-command","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"which-command","version":"0.1.0","description":"Find the absolute path to a command's executable, like the Unix `which` command","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/which-command.git"},"funding":"https://github.com/sindresorhus/which-command?sponsor=1","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","bin":{"which-command":"cli.js"},"exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=22"},"scripts":{"test":"xo && node --test"},"keywords":["which","where","command","executable","binary","path","find","locate","resolve","lookup","unix","cli","bin"],"devDependencies":{"xo":"^3.0.2"},"gitHead":"927ea950075962b744162cd08495a86f9fa22f4f","types":"./index.d.ts","_id":"which-command@0.1.0","bugs":{"url":"https://github.com/sindresorhus/which-command/issues"},"homepage":"https://github.com/sindresorhus/which-command#readme","_nodeVersion":"22.22.3","_npmVersion":"11.18.0","dist":{"integrity":"sha512-XZyoF5/5hZtXitIwzrU4NKK+Wtbb9aB9CezUEw2Q0wlYK8NUYQxC1rRXgNueYLtBAJwXIb+/tFVk4dozciNJMA==","shasum":"62828a961c1104d660fbdc397b5a540c629f3d6c","tarball":"https://registry.npmjs.org/which-command/-/which-command-0.1.0.tgz","fileCount":6,"unpackedSize":15855,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCID79LhJu5bnHNN7mKCEzYtFTd/AHmD8RAuXmTCgdrY4SAiBIXaO8xPnYmtnn0KMclUpju7Uawp6j2ZkkN8qg49r8bw=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/which-command_0.1.0_1783299641156_0.7009825972103465"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T01:00:41.084Z","0.1.0":"2026-07-06T01:00:41.306Z","modified":"2026-07-06T01:00:41.591Z"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"description":"Find the absolute path to a command's executable, like the Unix `which` command","homepage":"https://github.com/sindresorhus/which-command#readme","keywords":["which","where","command","executable","binary","path","find","locate","resolve","lookup","unix","cli","bin"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/which-command.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"bugs":{"url":"https://github.com/sindresorhus/which-command/issues"},"license":"MIT","readme":"# which-command\n\n> Find the absolute path to a command's executable, like the Unix [`which`](https://en.wikipedia.org/wiki/Which_(command)) command\n\nUseful for locating an executable in `PATH` before spawning it, checking whether a tool is installed, or building your own CLI tooling.\n\nWorks cross-platform, including Windows `PATHEXT` handling and App Execution Aliases.\n\n## Install\n\n```sh\nnpm install which-command\n```\n\n## Usage\n\n```js\nimport {whichCommand, whichCommandSync, whichCommandAll} from 'which-command';\n\nawait whichCommand('node');\n//=> '/usr/local/bin/node'\n\nawait whichCommand('does-not-exist');\n//=> undefined\n\nwhichCommandSync('node');\n//=> '/usr/local/bin/node'\n\nawait whichCommandAll('node');\n//=> ['/usr/local/bin/node', '/opt/homebrew/bin/node']\n```\n\n## API\n\n### whichCommand(command, options?)\n\nReturns a `Promise` for the absolute path to the first matching executable, or `undefined` if not found.\n\n### whichCommandSync(command, options?)\n\nSame as `whichCommand()`, but synchronous.\n\n### whichCommandAll(command, options?)\n\nReturns a `Promise` for an array of the absolute paths to all matching executables in `PATH` order, or an empty array if none are found. Like `which -a`.\n\n### whichCommandAllSync(command, options?)\n\nSame as `whichCommandAll()`, but synchronous.\n\n#### command\n\nType: `string`\n\nThe command name to look for, or a path to check directly.\n\nIf it contains a directory separator (like `./foo` or `/usr/bin/foo`), it's resolved directly instead of being searched for in `PATH`.\n\n#### options\n\nType: `object`\n\n##### cwd\n\nType: `string`\\\nDefault: [`process.cwd()`](https://nodejs.org/api/process.html#processcwd)\n\nThe directory to resolve relative paths against.\n\nRelative `path` entries and commands that contain a directory separator are resolved against this. On Windows, this directory is also searched before `PATH`.\n\n##### path\n\nType: `string`\\\nDefault: [`process.env.PATH`](https://en.wikipedia.org/wiki/PATH_(variable))\n\nThe `PATH` to search.\n\nEmpty entries are ignored. Unlike a POSIX shell, an empty entry is not treated as the current directory, since implicitly searching the current directory is a security risk.\n\n##### pathExt\n\nType: `string`\\\nDefault: `process.env.PATHEXT`\n\nThe executable file extensions to look for, as a `;`-separated string.\n\nOnly used on Windows. Corresponds to the [`PATHEXT`](https://learn.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v=office.14)) environment variable.\n\n## CLI\n\n```sh\n$ npx which-command --help\n\n  Usage\n    $ which-command <command> …\n\n  Options\n    --all, -a     List all matching paths, not just the first\n    --silent, -s  Suppress output; the exit code still reflects whether all commands were found\n\n  Examples\n    $ which-command node\n    /usr/local/bin/node\n\n    $ which-command --all node\n    /usr/local/bin/node\n    /opt/homebrew/bin/node\n\n  Exits with code 1 if any of the commands could not be found.\n```\n\n## FAQ\n\n### How is it better than the [`which`](https://github.com/npm/node-which) package?\n\n- Returns `undefined` when a command is not found, instead of throwing.\n- `whichCommandAll()` deduplicates results, so duplicate `PATH` entries don't produce duplicate matches.\n- Safer by default: empty `PATH` entries are ignored instead of implicitly searching the current directory.\n- Finds Windows App Execution Aliases (like the `python` and `winget` stubs in `WindowsApps`), which `which` skips.\n- Modern: pure ESM with bundled TypeScript types.\n","readmeFilename":"readme.md","_rev":"1-672ce47089fe28157dcb97a5f0b9cca9"}