The minimum and most straightforward way to check if command exists and where the executable is.
npm install lookpath






To check if the command exists and where the executable file is, WITHOUT using child_process.
```
npm install lookpath
`js
const { lookpath } = require('lookpath');
const p = await lookpath('bash');
// "/bin/bash", otherwise "undefined"
`
`js~/.bin
const p = await lookpath('bash', {
include: ['/home/hiromu/.bin'],
exclude: ['/mnt']
});
// include: Do scan also under /mnt
// exclude: Do NOT scan under `
- I don't want to spawn child_process in order to kick which, where, whereis, or command -v.exec.LookPath
- node.js - Node - check existence of command in path - Stack Overflow
- Node.js: Check if a command exists - Gist
- mathisonian/command-exists: node module to check if a command-line command exists - GitHub
- then I checked Go implementation of .$PATH
- src/os/exec/lp_unix.go - The Go Programming Language
- so I concluded that scanning under or $Path` is the best straightforward way to check if the command exists.
- https://github.com/otiai10/lookpath/issues
Any feedback would be appreciated ;)
