NPX(1)
π NPX(1) β the glow-up
okay bestie, welcome to npx β the little command that literally feeds you any binary from any npm package, local or plucked straight off the registry. this is the manual page for it, and no, it is not called "NPX(1)" for funsies β that's the actual page name, the section 1 one, so you can cite it in arguments. periodt. π
β¨ NAME β¨
npx β run a command from a local or remote npm package π«Ά
πΈ Synopsis
npx -- <pkg>[@<version>] [args...]
npx --package=<pkg>[@<version>] -- <cmd> [args...]
npx -c '<cmd> [args...]'
npx --package=foo -c '<cmd> [args...]'
π¦ DESCRIPTION π¦
so basically, this command lets you run an arbitrary command from an npm package β could be one already installed locally, could be one fetched remotely β and it does it in a context that's lowkey the same vibe as running it through npm run. iconic behavior honestly.
run this when you wanna execute a package's binary. real talk though: any options and arguments after the package name get passed directly to the executed command, not to npx itself. so like, npx create-react-app my-app --template typescript will hand my-app and --template typescript straight to the create-react-app command. if you wanna know what options a specific package accepts, go read that package's own docs (e.g., at npmjs.com or in its repository) β npx is not the one to ask, she's just the messenger. πββοΈ
whatever packages you name with the --package option get shoved into the PATH of the executed command, along with any locally installed package executables. and yes, you can drop --package multiple times β that's the whole trick for running a command in an environment where all the packages you listed are chilling and available. π
if any of the requested packages aren't already in your local project dependencies, they get installed to a folder in the npm cache, and that folder gets added to the PATH environment variable in the executed process. also, a prompt is printed β you can suppress it by providing either --yes or --no. β¨
π¨ package names given without a specifier get matched against whatever version already exists in the local project. package names with a specifier only count as a match if they have the exact same name and version as the local dependency. no fuzzy-matching, no "close enough", fr fr.
if you don't pass a -c or --call option, then the positional arguments get used to generate the command string. and if there are no --package options either, npm will attempt to determine the executable name from the package specifier you gave as the first positional argument β using this 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 gets used. - π if the package has multiple
binentries, and one of them matches the unscoped portion of thenamefield, then that command gets used. - π if this doesn't result in exactly one option (either 'cause there are no
binentries, or none of them match the name of the package), thennpm execexits with an error. not the vibe, but it's the rules.
wanna run a binary that isn't the named binary? just specify one or more --package options β doing that stops npm from inferring the package from the first command argument. genius little loophole tbh. π§
π npx vs npm exec π
bestie this is the part where people get got, so pay attention. π
when you run things via the npx binary, all flags and options must be set prior to any positional arguments. no exceptions. but 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. slay.
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
see what happened? since the --package option comes after the positional arguments, it gets treated as an argument to the executed command. it's giving "i'm just a passenger." π
in contrast, because of npm's argument parsing logic, running this command is different:
$ npm exec foo@latest bar --package=@npmcli/foo
here, npm parses the --package option first, resolving the @npmcli/foo package. then it executes the following command in that context:
$ foo@latest bar
so the double-hyphen character is recommended β it explicitly tells npm to stop parsing command line options and switches. which means the following command would be equivalent to the npx command from way up above:
$ npm exec -- foo@latest bar --package=@npmcli/foo
see? equivalence. harmony. balance restored. π¦β¨
π EXAMPLES π
run the version of tap that lives in your local dependencies, with the arguments you provided:
$ npm exec -- tap --bail test/foo.js
$ npx tap --bail test/foo.js
run a command that isn't the one matching 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"'
look at that say "hooray, lint passed" β main character energy, honestly. π
π§ Compatibility with Older npx Versions π§
story time π: the npx binary was rewritten in npm v7.0.0, and the standalone npx package was deprecated at that time. npx now 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 β and you need to know them:
- π any npm config value may be provided.
- π₯ to prevent security and user-experience problems from mistyping package names, npx prompts 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--packagein npx. this is maintained, but only for thenpxexecutable. - πΈ the
--ignore-existingoption is removed. locally installed bins are always present in the executed processPATH. - π¦ the
--npmoption is removed. npx will always use the npm it ships with. - π the
--node-argand-noptions have been removed. useNODE_OPTIONSinstead: 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.
π«Ά thatNODE_OPTIONSline is literally the whole migration path for--node-argand-n. screenshot it. memorize it. iykyk.
π 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 β no notes, no cap, every flag accounted for. π
shoutout to whoever maintains this thing: this is version NPM@11.19.1, dated August 2026. cute. iconic. historic. πβ¨
π¦ where this page comes from
- centos-stream 10: nodejs26-npm 1:11.19.1-1.26.8.2.1.el10 Β· Apache-2.0 AND Artistic-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BlueOak-1.0.0 AND CC-BY-3.0 AND CC0-1.0 AND ISC AND MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms