# The npx Node Package Runner

> Learn how npx runs commands from local or remote npm packages, how it relates to npm exec, and how to run a specific package version safely.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2018-07-19 | Updated: 2026-07-18 | Topics: [Node.js](https://flaviocopes.com/tags/node/) | Canonical: https://flaviocopes.com/npx/

`npx` runs a command from an npm package. It uses a locally installed package when available, or can fetch a package temporarily when it is missing.

`npx` ships with modern versions of [npm](https://flaviocopes.com/npm/). The old standalone `npx` package is deprecated.

## Run a local command

Suppose ESLint is installed in your project:

```bash
npm install --save-dev eslint
```

You can run its executable without knowing its path inside `node_modules`:

```bash
npx eslint .
```

This is the main reason to use `npx`: project tools stay local, and every project can use its own version.

Inside a `package.json` script you normally do not need `npx`. npm already adds local package executables to the script's `PATH`.

## Run a package without adding it to the project

You can also run a command that is not installed locally:

```bash
npx cowsay "Hello"
```

npx tells you that it needs to install the missing package and asks for confirmation. Pass `--yes` only when you have already checked the package name and trust the code:

```bash
npx --yes cowsay "Hello"
```

The package is fetched into npm's cache for the command. It is not added to your project's `dependencies`.

Be careful with typos. Running an unfamiliar package means running code downloaded from the registry on your computer.

## Run a specific version

Add a version after the package name:

```bash
npx cowsay@1.6.0 "Hello"
```

This is useful when documentation or a project requires a particular release.

## npx and npm exec

Modern `npx` is based on `npm exec`. These commands are equivalent for many common cases:

```bash
npx eslint .
npm exec -- eslint .
```

There is one syntax detail worth remembering: options before the package name belong to `npx`; options after it are passed to the command being run.

The [official npx documentation](https://docs.npmjs.com/cli/v11/commands/npx/) lists the differences between `npx` and `npm exec`, including compatibility changes made when npx was rewritten in npm 7.
