function

which

function which(
command: string,
options?: WhichOptions
): null | string;

Find the path to an executable, like the which command in your terminal. Reads the PATH environment variable unless overridden with options.PATH.

@param command

The name of the executable or script to find

@param options

Options for the search

@returns

The path to the executable, or null if it isn't found

Referenced types

interface WhichOptions

  • cwd?: string

    When command is a relative path, resolve it against this directory.

  • PATH?: string

    Overrides the PATH environment variable