Home·Terminal commands

npx

Packages and runtimes

Usage

npx [-y] <package>[@version] [args...]

Runs a package binary, preferring node_modules/.bin and otherwise fetching it temporarily; because a typo can pull a stranger package from the registry, --no keeps it local-only.

Common flags

FlagMeaning
-yinstall without asking first
--nofail instead of downloading anything
-p <pkg>make a package available, then run a command from it
-c "<cmd>"run the command through a shell with the bin path set
--package <pkg>the long form of -p

Examples

npx tsc --noEmit

runs the typescript in node_modules, no global install

npx -y create-next-app@latest my-app

fetches a scaffolder for one use and forgets it

npx --no eslint .

uses the local eslint or fails, instead of quietly downloading one

The question is always what goes where: inside this project, or on the whole machine.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does npx do?

Runs a package binary, preferring node_modules/.bin and otherwise fetching it temporarily; because a typo can pull a stranger package from the registry, --no keeps it local-only.

Q. How do I type it?

npx [-y] <package>[@version] [args...] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

5 are listed here; the full set is in man npx. This command sits under Packages and runtimes.

Related commands

man page: man npx