npx (Node.js)

npx is a tool bundled with npm that runs a package's command without installing it globally. It downloads the package on demand (or uses a local copy), executes it, and is ideal for one-off CLI tools and scaffolders.

Node.js

npx solves the annoyance of installing a command-line tool just to run it once. npx create-react-app my-app fetches create-react-app temporarily, runs it to scaffold your project, and leaves nothing installed globally afterward, so you always use the latest version.

It also runs binaries already installed in your project's node_modules/.bin, so npx jest uses your project's local Jest version rather than a global one — handy for keeping tool versions consistent with the project.

Use npx for scaffolding (create-* tools), running local dev dependencies, and trying a CLI without a global install. For tools you run constantly you might still install them, but npx keeps your global environment clean and your tool versions current.

Syntax

npx <package> [args]

Examples

JavaScript

// run a scaffolder without installing it
// npx create-react-app my-app

// run the project's local eslint
// npx eslint src/

Learn it in a lesson

See also

Back to the Dictionary