Detect if executable exists on system path with node

Question

Is there a simple way to tell if a system executable is available on the system path using node? For example if a user has python installed at /usr/bin/python and /usr/bin is in $PATH how can I detect that in Node? And conversely detect when something isn't installed or is just not on path, i.e. /usr/opt/local/mycustompath/python? Ideally hoping their is an npm package available ...

I'm sure this is a quick google search with the right search term, but I'm failing due to the fact where and which are pretty generic search terms.

Background

I'm working on some dev config for a node tool and would like to be able to detect whether python (or pip) is already available on path, and if not, ask the user to tell install it or tell us where to find it. I'm currently planning on doing this with where on windows machines and which on *nix machines, but was hoping there might be a single cross platform way of doing this.

You have to find a way to do it, as there is no "generic" or "out-of-box" way to do it.

One way is, you can use check if the desired package/binary is installed via your package manager then you can use utility whereis which attempts to locate the desired program in a list of standard Linux places, listed in $PATH.

Of course you can use also the utility which but whereis provides a bit more information. You can check about the difference of which and whereis here.

Generally speaking, as in your example, user might has manually installed some package at some random location, but not listed in $PATH. In this way there is no way to check if the package is installed at all, rather than to try to find the binary name or related files in complete tree of file system.