# npm-run

> Run executables for locally-installed packages without using ./node_modules/.bin

Latest version **5.0.1** (published 2018-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-run
pnpm add npm-run
yarn add npm-run
bun add npm-run
```

Provides the command `npm-run`.

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.1 |
| Published | 2018-04-12 |
| First published | 2014-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/npm-run) |
| Module format | CommonJS |
| Node | >=4.2.0 |
| Dependencies | 4 |
| Unpacked size | 19.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 186 |
| Author | Tim Oxley |
| Maintainers | timoxley |
| Keywords | npm, path, executable, .bin, run |

## Links

- npm: https://www.npmjs.com/package/npm-run
- Repository: https://github.com/timoxley/npm-run
- Issues: https://github.com/timoxley/npm-run/issues
- npm.io page: https://npm.io/package/npm-run

## Dependencies (4)

- [minimist](https://npm.io/package/minimist.md) ^1.2.0
- [npm-path](https://npm.io/package/npm-path.md) ^2.0.4
- [npm-which](https://npm.io/package/npm-which.md) ^3.0.1
- [serializerr](https://npm.io/package/serializerr.md) ^1.0.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 5.0.1 (latest) — 2018-04-12
- 5.0.0 — 2018-04-10
- 4.1.2 — 2017-03-17
- 4.1.1 — 2017-03-02
- 4.1.0 — 2016-07-22
- 4.0.1 — 2016-07-22
- 4.0.0 — 2016-07-22
- 3.0.0 — 2016-02-25
- 2.0.0 — 2015-03-22
- 1.1.1 — 2015-03-06
- 1.1.0 — 2015-03-06
- 1.0.2 — 2014-06-28
- 1.0.1 — 2014-06-23
- 1.0.0 — 2014-04-23

## README

# npm-run

[![NPM](https://nodei.co/npm/npm-run.png?downloads=true&downloadRank=true)](https://nodei.co/npm-dl/npm-run/)
[![NPM](https://nodei.co/npm-dl/npm-run.png?months=3&height=3&chrome)](https://nodei.co/npm/npm-run/)

[![Build Status](https://travis-ci.org/timoxley/npm-run.svg?branch=master)](https://travis-ci.org/timoxley/npm-run)

### Run executables in node_modules from the command-line

Use `npm-run` to ensure you're using the same version of a package on the command-line and in package.json scripts.

Any executable available to an npm lifecycle script is available to `npm-run`.

## Usage

```bash
> npm install mocha # mocha installed in ./node_modules
> npm-run mocha test/* # uses locally installed mocha executable 
```

```bash
> npm-run --help
Usage: npm-run command [...args]
Options:
  --version  Display version & exit.
  --help     Display this help & exit.

Hint: to print augmented path use:
npm-run node -p process.env.PATH
```

## Installation

```bash
> npm install -g npm-run
```

## Programmatic API

The API of `npm-run` basically wraps core `child_process` methods (exec, spawn, etc) such that locally install package executables will be on the PATH when the command runs.

## npmRun(command[, options], callback)

Alias of npmRun.exec.

## npmRun.exec(command[, options], callback)

Takes same arguments as node's [exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).

```js
npmRun.exec('mocha --debug-brk --sort', {cwd: __dirname + '/tests'}, function (err, stdout, stderr) {
  // err Error or null if there was no error
  // stdout Buffer|String
  // stderr Buffer|String
})
```

## npmRun.sync(command[, options])

Alias of npmRun.execSync

## npmRun.execSync(command[, options])

Takes same arguments as node's [execSync](https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options).

```js
var stdout = npmRun.execSync(
  'mocha --debug-brk --sort',
  {cwd: __dirname + '/tests'}
)
stdout // command output as Buffer|String
```

## npmRun.spawnSync(command[, args][, options])

Takes same arguments as node's [spawnSync](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options).

```js
var child = npmRun.spawnSync(
  'mocha',
  '--debug-brk --sort'.split(' '),
  {cwd: __dirname + '/tests'}
)
child.stdout // stdout Buffer|String
child.stderr // stderr Buffer|String
child.status // exit code
```

## npmRun.spawn(command[, args][, options])

Takes same arguments as node's [spawn](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).

```js
var child = npmRun.spawn(
  'mocha',
  '--debug-brk --sort'.split(' '),
  {cwd: __dirname + '/tests'}
)
child.stdout // stdout Stream
child.stderr // stderr Stream
child.on('exit', function (code) {
  code // exit code
})
```

## Why

Due to npm's install algorithm `node_modules/.bin` is not guaranteed to contain your executable. `npm-run` uses the same mechanism npm uses to locate the correct executable.

### See Also

* [timoxley/npm-which](https://github.com/timoxley/npm-which)
* [timoxley/npm-path](https://github.com/timoxley/npm-path)
* [grncdr/npm-exec](https://github.com/grncdr/npm-exec)

## License

MIT

---
_Source: https://npm.io/package/npm-run · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
