1# libnpmexec 2 3[](https://npm.im/libnpmexec) 4[](https://npm.im/libnpmexec) 5[](https://github.com/npm/cli/actions/workflows/ci-libnpmexec.yml) 6 7The `npm exec` (`npx`) Programmatic API 8 9## Install 10 11`npm install libnpmexec` 12 13## Usage: 14 15```js 16const libexec = require('libnpmexec') 17await libexec({ 18 args: ['yosay', 'Bom dia!'], 19 cache: '~/.npm/_cacache', 20 npxCache: '~/.npm/_npx', 21 yes: true, 22}) 23``` 24 25## API: 26 27### `libexec(opts)` 28 29- `opts`: 30 - `args`: List of pkgs to execute **Array<String>**, defaults to `[]` 31 - `call`: An alternative command to run when using `packages` option **String**, defaults to empty string. 32 - `cache`: The path location to where the npm cache folder is placed **String** 33 - `npxCache`: The path location to where the npx cache folder is placed **String** 34 - `chalk`: Chalk instance to use for colors? **Required** 35 - `localBin`: Location to the `node_modules/.bin` folder of the local project to start scanning for bin files **String**, defaults to `./node_modules/.bin`. **libexec** will walk up the directory structure looking for `node_modules/.bin` folders in parent folders that might satisfy the current `arg` and will use that bin if found. 36 - `locationMsg`: Overrides "at location" message when entering interactive mode **String** 37 - `globalBin`: Location to the global space bin folder, same as: `$(npm bin -g)` **String**, defaults to empty string. 38 - `output`: A function to print output to **Function** 39 - `packages`: A list of packages to be used (possibly fetch from the registry) **Array<String>**, defaults to `[]` 40 - `path`: Location to where to read local project info (`package.json`) **String**, defaults to `.` 41 - `runPath`: Location to where to execute the script **String**, defaults to `.` 42 - `scriptShell`: Default shell to be used **String**, defaults to `sh` on POSIX systems, `process.env.ComSpec` OR `cmd` on Windows 43 - `yes`: Should skip download confirmation prompt when fetching missing packages from the registry? **Boolean** 44 - `registry`, `cache`, and more options that are forwarded to [@npmcli/arborist](https://github.com/npm/arborist/) and [pacote](https://github.com/npm/pacote/#options) **Object** 45 46## LICENSE 47 48[ISC](./LICENSE) 49