NPX(1)
π NPX(1) β the npx girlies' manual π
okay bestie, welcome to the npx page, manual section 1. pull up a chair, grab a strawberry π, and let's get into it. no cap, this one's iconic.
β¨ NAME β¨
npx β run a command from a local or remote npm package. yeah. that's the whole vibe. run a thing, from a package, local or remote. π
β¨ Synopsis β¨
npx -- <pkg>[@<version>] [args...]
npx --package=<pkg>[@<version>] -- <cmd> [args...]
npx -c '<cmd> [args...]'
npx --package=foo -c '<cmd> [args...]'
look at those four lil lines. four whole ways to pop off. πΈ
β¨ Description β¨
so basically: this command lets you run an arbitrary command from an npm package β and that package can either be one installed locally or one fetched remotely. the context it runs in is similar to running it via npm run. π«Ά
run this command to execute a package's binary. any options and arguments after the package name get passed directly to the executed command, not to npx itself. for example, npx create-react-app my-app --template typescript will pass my-app and --template typescript to the create-react-app command. so if you wanna know what options a specific package accepts? go consult that package's documentation (like at npmjs.com or in its repository). npx is not the one holding that lore, iykyk. π
whatever packages are specified by the --package option will be provided in the PATH of the executed command, along with any locally installed package executables. and bestie β the --package option may be specified multiple times, so you can execute the supplied command in an environment where all specified packages are available. stacking packages like it's a fit check. π
if any requested packages are not present in the local project dependencies, then they get installed to a folder in the npm cache, which is added to the PATH environment variable in the executed process. and a prompt is printed β which you can suppress by providing either --yes or --no. it's giving "consent first, bestie." π
package names provided without a specifier will be matched with whatever version exists in the local project. package names with a specifier will only be considered a match if they have the exact same name and version as the local dependency. exact. same. name. and. version. no wiggle room, no vibes-based matching. π
if no -c or --call option is provided, then the positional arguments are used to generate the command string. and if no --package options are provided, then npm will attempt to determine the executable name from the package specifier provided as the first positional argument, according to the following heuristic:
- if the package has a single entry in its
binfield inpackage.json, or if all entries are aliases of the same command, then that command will be used. - if the package has multiple
binentries, and one of them matches the unscoped portion of thenamefield, then that command will be used. - if this does not result in exactly one option (either because there are no
binentries, or none of them match the name of the package), thennpm execexits with an error. π not the ambiguous-bin situation.
to run a binary other than the named binary, specify one or more --package options, which will prevent npm from inferring the package from the first command argument.
β¨ npx vs npm exec β¨
okay so when you run via the npx binary, all flags and options must be set prior to any positional arguments. periodt. when you run via npm exec, a double-hyphen -- flag can be used to suppress npm's parsing of switches and options that should be sent to the executed command. π¦
for example:
$ npx foo@latest bar --package=@npmcli/foo
in this case, npm will resolve the foo package name, and run the following command:
$ foo bar --package=@npmcli/foo
since the --package option comes after the positional arguments, it is treated as an argument to the executed command. sneaky little guy. π
in contrast, due to npm's argument parsing logic, running this command is different:
$ npm exec foo@latest bar --package=@npmcli/foo
in this case, npm will parse the --package option first, resolving the @npmcli/foo package. then, it will execute the following command in that context:
$ foo@latest bar
the double-hyphen character is recommended to explicitly tell npm to stop parsing command line options and switches. the following command would thus be equivalent to the npx command above:
$ npm exec -- foo@latest bar --package=@npmcli/foo
see how that works? -- is the "okay we're done talking to npm, talk to the command now" line. icon behavior. β
β¨ Examples β¨
run the version of tap in the local dependencies, with the provided arguments:
$ npm exec -- tap --bail test/foo.js
$ npx tap --bail test/foo.js
run a command other than the command whose name matches the package name by specifying a --package option:
$ npm exec --package=foo -- bar --bar-argument
# ~ or ~
$ npx --package=foo bar --bar-argument
run an arbitrary shell script, in the context of the current project:
$ npm x -c 'eslint && say "hooray, lint passed"'
$ npx -c 'eslint && say "hooray, lint passed"'
that second one is my favorite fr fr, say "hooray, lint passed" is literally me every time CI goes green. ππ
β¨ Compatibility with Older npx Versions β¨
lore time, bestie. π the npx binary was rewritten in npm v7.0.0, and the standalone npx package was deprecated at that time. npx uses the npm exec command instead of a separate argument parser and install process, with some affordances to maintain backwards compatibility with the arguments it accepted in previous versions.
this resulted in some shifts in its functionality:
- any npm config value may be provided. π
- to prevent security and user-experience problems from mistyping package names,
npxprompts before installing anything. suppress this prompt with the-yor--yesoption. - the
--no-installoption is deprecated, and will be converted to--no. - shell fallback functionality is removed, as it is not advisable.
- the
-pargument is a shorthand for--parseablein npm, but shorthand for--packageinnpx. this is maintained, but only for thenpxexecutable. (chaos, honestly, but it's kept. π) - the
--ignore-existingoption is removed. locally installed bins are always present in the executed processPATH. - the
--npmoption is removed.npxwill always use the npm it ships with. - the
--node-argand-noptions have been removed. useNODE_OPTIONSβ¨https://nodejs.org/api/cli.html#node_optionsoptionsβ© instead: e.g.,NODE_OPTIONS="--trace-warnings --trace-exit" npx foo --random=true - the
--always-spawnoption is redundant, and thus removed. - the
--shelloption is replaced with--script-shell, but maintained in thenpxexecutable for backwards compatibility.
so like... a lot of old flags just do not exist anymore, bestie. if a tutorial from 2019 tells you to use--npmor-n, it's over. useNODE_OPTIONSinstead. π«Ά
β¨ See Also β¨
npm help runnpm help scriptsnpm help testnpm help startnpm help restartnpm help stopnpm help confignpm help exec
and that's the whole page, bestie. π¦ you just ate this documentation up, no crumbs. this was npx from NPM@11.16.0, dated May 2026. mwah. π
β¨π
π¦ where this page comes from
- opensuse-leap 16.0: npm24 24.18.1-160000.1.1 Β· MIT
- opensuse-leap 16.0: npm24 24.18.1-160000.1.1 Β· MIT
- opensuse-leap 16.0: npm24 24.18.1-160000.1.1 Β· MIT
- opensuse-leap 16.0: npm24 24.18.1-160000.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms