Détail du package

npx

npm542.4kISCobsolète10.2.2

This package is now part of the npm CLI.

execute npm package binaries

npm, npm exec, shell, scripts

readme

npm license Travis AppVeyor Coverage Status

npx(1) -- execute npm package binaries

SYNOPSIS

npx [options] <command>[@version] [command-arg]...

npx [options] [-p|--package <pkg>]... <command> [command-arg]...

npx [options] -c '<command-string>'

npx --shell-auto-fallback [shell]

INSTALL

npm install -g npx

DESCRIPTION

Executes <command> either from a local node_modules/.bin, or from a central cache, installing any packages needed in order for <command> to run.

By default, npx will check whether <command> exists in $PATH, or in the local project binaries, and execute that. If <command> is not found, it will be installed prior to execution.

Unless a --package option is specified, npx will try to guess the name of the binary to invoke depending on the specifier provided. All package specifiers understood by npm may be used with npx, including git specifiers, remote tarballs, local directories, or scoped packages.

If a full specifier is included, or if --package is used, npx will always use a freshly-installed, temporary version of the package. This can also be forced with the --ignore-existing flag.

  • -p, --package <package> - define the package to be installed. This defaults to the value of <command>. This is only needed for packages with multiple binaries if you want to call one of the other executables, or where the binary name does not match the package name. If this option is provided <command> will be executed as-is, without interpreting @version if it's there. Multiple --package options may be provided, and all the packages specified will be installed.

  • --no-install - If passed to npx, it will only try to run <command> if it already exists in the current path or in $prefix/node_modules/.bin. It won't try to install missing commands.

  • --cache <path> - set the location of the npm cache. Defaults to npm's own cache settings.

  • --userconfig <path> - path to the user configuration file to pass to npm. Defaults to whatever npm's current default is.

  • -c <string> - Execute <string> inside an npm run-script-like shell environment, with all the usual environment variables available. Only the first item in <string> will be automatically used as <command>. Any others must use -p.

  • --shell <string> - The shell to invoke the command with, if any.

  • --shell-auto-fallback [<shell>] - Generates shell code to override your shell's "command not found" handler with one that calls npx. Tries to figure out your shell, or you can pass its name (either bash, fish, or zsh) as an option. See below for how to install.

  • --ignore-existing - If this flag is set, npx will not look in $PATH, or in the current package's node_modules/.bin for an existing version before deciding whether to install. Binaries in those paths will still be available for execution, but will be shadowed by any packages requested by this install.

  • -q, --quiet - Suppressed any output from npx itself (progress bars, error messages, install reports). Subcommand output itself will not be silenced.

  • -n, --node-arg - Extra node argument to supply to node when binary is a node script. You can supply this option multiple times to add more arguments.

  • -v, --version - Show the current npx version.

EXAMPLES

Running a project-local bin

$ npm i -D webpack
$ npx webpack ...

One-off invocation without local installation

$ npm rm webpack
$ npx webpack -- ...
$ cat package.json
...webpack not in "devDependencies"...

Invoking a command from a github repository

$ npx github:piuccio/cowsay
...or...
$ npx git+ssh://my.hosted.git:cowsay.git#semver:^1
...etc...

Execute a full shell command using one npx call w/ multiple packages

$ npx -p lolcatjs -p cowsay -c \
  'echo "$npm_package_name@$npm_package_version" | cowsay | lolcatjs'
...
 _____
< your-cool-package@1.2.3 >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Run node binary with --inspect

$ npx --node-arg=--inspect cowsay
Debugger listening on ws://127.0.0.1:9229/....

Specify a node version to run npm scripts (or anything else!)

npx -p node@8 npm run build

SHELL AUTO FALLBACK

You can configure npx to run as your default fallback command when you type something in the command line with an @ but the command is not found. This includes installing packages that were not found in the local prefix either.

For example:

$ npm@4 --version
(stderr) npm@4 not found. Trying with npx...
4.6.1
$ asdfasdfasf
zsh: command not found: asfdasdfasdf

Currently, zsh, bash (>= 4), and fish are supported. You can access these completion scripts using npx --shell-auto-fallback <shell>.

To install permanently, add the relevant line below to your ~/.bashrc, ~/.zshrc, ~/.config/fish/config.fish, or as needed. To install just for the shell session, simply run the line.

You can optionally pass through --no-install when generating the fallback to prevent it from installing packages if the command is missing.

For bash@>=4:

$ source <(npx --shell-auto-fallback bash)

For zsh:

$ source <(npx --shell-auto-fallback zsh)

For fish:

$ source (npx --shell-auto-fallback fish | psub)

ACKNOWLEDGEMENTS

Huge thanks to Kwyn Meagher for generously donating the package name in the main npm registry. Previously npx was used for a Tessel board Neopixels library, which can now be found under npx-tessel.

AUTHOR

Written by Kat Marchan.

REPORTING BUGS

Please file any relevant issues on Github.

LICENSE

This work is released by its authors into the public domain under CC0-1.0. See LICENSE.md for details.

SEE ALSO

  • npm(1)
  • npm-run-script(1)
  • npm-config(7)

changelog

Change Log

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

10.2.2 (2020-01-28)

Bug Fixes

  • correct Kat's github url (9a23db1)
  • install latest npm on travis for node 6 (e0eb3cb)
  • Update changelog to fix old issue links (3733137)

10.2.0 (2018-04-13)

Bug Fixes

  • i18n: fix korean; 쉘 -> 셸 (#163) (11d9fe0)
  • spawn: spawn child processes with node without relying on the shebang. (#174) (cba97bb)
  • windows: Allow spaces in the node path when using --node-arg (#173) (fe0d48a), closes #170

Features

10.1.1 (2018-04-12)

10.1.0 (2018-04-12)

Features

  • spawn: add --always-spawn to opt out of process takeover optimization feature (#172) (c0d6abc)

10.0.1 (2018-03-08)

Bug Fixes

  • i18n: Improve French localization (#158) (c88823e)
  • windows: on Windows, throw useful error when package contains no binaries(#142) (a69276e), closes #137

10.0.0 (2018-03-08)

Bug Fixes

BREAKING CHANGES

  • license: This moves the code over from CC0-1.0 to the ISC license.

9.7.1 (2017-10-19)

Bug Fixes

9.7.0 (2017-10-19)

Bug Fixes

  • exec: fixed unix binary pathing issues (#120) (f80a970), closes #120

Features

  • child: add opts.installerStdio (#126) (ade03f7)

9.6.0 (2017-08-17)

Features

  • i18n: add Arabic translation (#111) (3c5b99a)
  • i18n: add Dutch (#108) (ed116fd)

9.5.0 (2017-07-28)

Features

  • i18n: add Polish translations (#99) (8442f59)

9.4.1 (2017-07-21)

Bug Fixes

  • i18n: fix filename for uk.json locale (2c770e4)

9.4.0 (2017-07-21)

Bug Fixes

  • i18n: minor fixes to ru locale (#92) (f4d5051), closes #92

Features

  • i18n: no locale fallback for Norwegian bokmål ⚠️ In case of weird setups ⚠️ (#91) (74f0e4c)
  • i18n: add Bahasa Indonesia locale (#95) (80dceeb)
  • i18n: add serbian translation (#96) (040de7a)
  • i18n: add Ukrainian locale (#93) (9a3ef33)
  • i18n: Added Norwegian (bokmål and nynorsk) translations (#90) (6c5c733)

9.3.2 (2017-07-17)

Bug Fixes

  • exec: detect a wider range of shebang lines for node scripts (#89) (1841b6f)
  • windows: escape spawn args because windows is picky (#87) (314e5eb)
  • windows: get magic shim detection working on Windows (#88) (255aeeb)

9.3.1 (2017-07-17)

Bug Fixes

9.3.0 (2017-07-17)

Features

  • i18n: add Korean locale (#86) (3655314)

9.2.3 (2017-07-17)

Bug Fixes

  • paths: support npm/npx paths with spaces in them (8f3b829)

9.2.2 (2017-07-15)

Bug Fixes

  • npm: escape path to npm, too (333d2ff)

9.2.1 (2017-07-14)

Bug Fixes

  • windows: fixed windows binary pathing issues (761dfe9)

9.2.0 (2017-07-14)

Bug Fixes

  • binpath: fix calling binaries from subdirectories (f185d0d)
  • i18n: Fix typos in french locale (#78) (f277fc7), closes #78

Features

  • i18n: Add German translations (#79) (c81e26d)
  • i18n: add zh_TW translation (#80) (98288d8)

9.1.0 (2017-07-12)

Bug Fixes

  • call: only npm run env if package.json exists (370f395)
  • i18n: Fix grammar and spelling for de.json (#63) (b14020f), closes #63
  • i18n: wording revisions for Brazilian Portuguese (#75) (b5dc536)
  • npm: path directly to the npm-cli.js script (d531206)
  • rimraf: fix rimraf.sync is not a function issue (d2ecba3)
  • windows: get npx working well on Windows again (#69) (6cfb8de), closes #60 #58 #62

Features

  • i18n: add Czech translation (#76) (8a0b3f6)
  • i18n: Add Turkish translation (#73) (26e5edf)
  • i18n: Added support for Italian language (#71) (6883e75)
  • i18n: Fix Romanian translation (#70) (fd6bbcf), closes #70
  • node: add --node-arg support to pass flags to node for script binaries (#77) (65665bd)

9.0.7 (2017-07-11)

Bug Fixes

  • i18n: Fix some Catalan translations (#59) (11c8a19), closes #59

9.0.6 (2017-07-11)

Bug Fixes

  • auto-fallback: fix syntax error in bash/zsh auto-fallback (d8b19db)

9.0.5 (2017-07-11)

Bug Fixes

  • npx: something went wrong with the 9.0.4 build and bundledeps (75fc436)

9.0.4 (2017-07-11)

Bug Fixes

  • auto-fallback: prevent infinite loop if npx disappears (6c24e58)
  • bin: add repository and more detailed author info (906574e)
  • bin: pin the npx bin's dependencies (ae62f7a)
  • build: make sure changelog and license are copied to bin (4fbb599)
  • deps: stop bundling deps in libnpx itself (c3e56e9)
  • errors: print command not found for packages without valid binaries (9b24359)
  • help: --no-install help text was contradicting itself (9d96f5e)
  • install: prevent concurrent npx runs from clobbering each other (6b35c91)
  • npx: npx npx npx npx npx npx npx npx npx works again (875d4cd)
  • updater: dependency injection for update-notifier target (c3027a9)
  • updater: ignore some kinds of update-notifier errors (7631bbe)

9.0.3 (2017-07-08)

Bug Fixes

  • version: hand version to yargs directly (e0b5eeb)

9.0.2 (2017-07-08)

Bug Fixes

  • manpage: fix manpage for real because files syntax is weird (9145e2a)

9.0.1 (2017-07-08)

Bug Fixes

  • man: make sure manpage is used in npx bin (704b94f)

9.0.0 (2017-07-08)

Features

  • libnpx: libify main npx codebase (643f58e)
  • npx: create a new binary for standalone publishing (da5a3b7)

BREAKING CHANGES

  • libnpx: This version of npx can no longer be used as a standalone binary. It will be available on the registry as libnpx, and a separate project will take over the role of the main npx binary.

8.1.1 (2017-07-06)

Bug Fixes

  • deps: bump all deps (6ea24bf)
  • npm: bump npm to 5.1.0 for a bunch of fixes (18e4587)

8.1.0 (2017-06-27)

Bug Fixes

  • i18n: minor tweaks to ja.json (#46) (1ed63c2)

Features

  • i18n: Update pt_BR.json (#51) (d292f22)

8.0.1 (2017-06-27)

Bug Fixes

  • npm: bump npm version for more bugfixes (30711a8)
  • npm: Use --parseable option to work around output quirks (8cb75a2)

8.0.0 (2017-06-24)

Features

  • exec: auto-guess binaries when different from pkg name (139c434)

BREAKING CHANGES

  • exec: npx ember-cli and such things will now execute the binary based on some guesswork, but only when using the shorthand format for npx execution, with no -p option or -c. This might cause npx to unintentionally execute the wrong binary if the package in question has multiple non-matching binaries, but that should be rare.

7.0.0 (2017-06-24)

Bug Fixes

  • win32: improve win32 situation a bit (#50) (b7ad934)

Features

  • local: improve the behavior when calling ./local paths (#48) (2e418d1)

BREAKING CHANGES

  • local: npx ./something will now execute ./something as a binary or script instead of trying to install it as npm would. Other behavior related to local path deps has likewise been changed. See #49 for a detailed explanation of all the various cases and how each of them is handled.

6.2.0 (2017-06-23)

Bug Fixes

  • child: iron out a few crinkles and add tests (b3b5ef6)
  • execCmd: only reuse the current process if no shell passed in (e413cff)
  • execCmd: use the module built-in directly (6f741c2)
  • help: fuck it. just hard-code it (d5d5085)
  • main: only exec if this is the main module (9631e2a)

Features

  • i18n: Update fr.json (#44) (ea47c4f)
  • i18n: update the Romanian translation. (#42) (2ed36b6)

6.1.0 (2017-06-21)

Bug Fixes

  • deps: remove unused gauge dep (aa40a34)

Features

  • i18n: update ru locale (#41) (7c84dee)
  • i18n: update zh_CN (#40) (da4ec67)
  • perf: run node-based commands in the current process (6efcde4)

6.0.0 (2017-06-20)

Bug Fixes

  • call: stop parsing -c for commands + fix corner cases (bd4e538)
  • child: exec does not have the information needed to correctly escape its args (6714992)
  • guessCmdName: tests failed because of lazy npa (53a0119)
  • i18n: gender inclusiveness fix for french version (#37) (04920ae), closes #37
  • i18n: typo 😇 (#38) (ede4a53)
  • install: handle JSON parsing failures (bec2887)
  • output: stop printing out Command Failed messages (873cffe)
  • parseArgs: fix booboo in fast path (d1e5487)
  • perf: fast-path npx foo arg parsing (ba4fe71)
  • perf: remove bluebird and defer some requires for SPEED (00fc313)

Features

  • i18n: add Romanian translations. (#34) (9e98bd0)
  • i18n: added a few more localizable strings (779d950)
  • i18n: updated ca.json (af7a035)
  • i18n: updated es.json (414644f)
  • i18n: updated ja.json (448b082)
  • i18n: Ze German Translation (#35) (6f003f5)
  • package: report number of temp packages installed (5b7fe8d)
  • perf: only launch update-notifier when npx installs stuff (549d413)
  • quiet: added -q/--quiet to suppress output from npx itself (16607d9)

BREAKING CHANGES

  • call: npx -c "foo" will no longer install foo. Use -p to specicify packages to install. npx will no longer assume any particular format or escape status for -c strings: they will be passed directly, unparsed, and unaltered, to child_process.spawn.

5.4.0 (2017-06-17)

Bug Fixes

  • i18n: some corrections for es.json (4d50b71)
  • i18n: update locale files with bugfixes (77caf82)
  • i18n: Y utility was ignoring falsy entries (f22a4d0)
  • i18n: してください -> します (01671af)

Features

  • i18n: add catalan translation (579efa1)
  • i18n: add pt-br translation (#33) (6142551)
  • i18n: added largely machine-translated ja.json (827705f)
  • i18n: adds russian translation (#32) (b2619c1)

5.3.0 (2017-06-13)

Features

  • i18n: add Chinese translation (#31) (24e1b31)

5.2.0 (2017-06-12)

Bug Fixes

  • i18n: removing extra spacing in fr.json (002e2b8)

Features

  • i18n: add french locale (#29) (662395b)

5.1.3 (2017-06-12)

Bug Fixes

  • fallback: put the Y in the wrong place lol (d6bf8aa)

5.1.2 (2017-06-10)

5.1.1 (2017-06-10)

Bug Fixes

  • i18n: forgot to add locales to files (4118d6a)

5.1.0 (2017-06-10)

Bug Fixes

  • exit: let process exit normally to finish writes (c50a398)

Features

  • i18n: added es.json (6cf58b9)
  • i18n: set up i18n plus baseline en.json locale (b67bb3a)

5.0.3 (2017-06-09)

Bug Fixes

5.0.2 (2017-06-09)

Bug Fixes

  • fallback: allow fallback to local anyway (569cf2c)

5.0.1 (2017-06-09)

5.0.0 (2017-06-09)

Features

  • fallback: by default, only fall back if you have an @ in the name (bea08a0)

BREAKING CHANGES

  • fallback: auto-fallback will no longer fall back unless there was an @ sign in the command.

4.0.3 (2017-06-04)

Bug Fixes

  • npm: use --userconfig when querying for npm cache config (#28) (21bc3bf)

4.0.2 (2017-06-04)

Bug Fixes

  • install: get windows workin (#27) (9472175)

4.0.1 (2017-06-04)

Bug Fixes

  • cmd: make sure to use our own, enriched path (9c89c2a)
  • error: join args with a space on Command failed error (c2f6f18)

4.0.0 (2017-06-03)

Features

  • call: -c now loads same env as run-script (76ae44c)
  • npm: allow configuration of npm binary (e5d5634)
  • npm: embed npm binary (a2cae9d)

BREAKING CHANGES

  • call: scripts invoked with -c will now have a bunch of variables added to them that were not there before.
  • npm: npx will no longer use the system npm -- it embeds its own

3.0.0 (2017-06-03)

Bug Fixes

  • args: accept argv as arg and fix minor bugs (46f10fe)
  • deps: explicitly add mkdirp and rimraf to devDeps (832c75d)
  • docs: misc tweaks to docs (ed70a7b)
  • exec: escape binaries and args to cp.exec (#18) (55d6a11)
  • fallback: shells were sometimes ignored based on $SHELL (07b7efc)
  • get-prefix: nudge isRootPath (1ab31eb)
  • help: correctly enable -h and --help (adc2f45)
  • startup: delay loading some things to speed up startup (6b32bf5)

Features

  • cmd: do some heuristic guesswork on default command names (#23) (2404420)
  • ignore: add --ignore-existing option (#20) (0866a83)
  • install: added --no-install option to prevent install fallbacks (a5fbdaf)
  • package: multiple --package options are now accepted (f2fa6b3)
  • save: remove all save-related functionality (#19) (ab77f6c)
  • shell: run -c strings inside a system shell (#22) (17db461)

BREAKING CHANGES

  • save: npx can no longer be used to save packages locally or globally. Use an actual package manager for that, instead.

2.1.0 (2017-06-01)

Features

  • opts: add --shell-auto-fallback (#7) (ac9cb40)

2.0.1 (2017-05-31)

Bug Fixes

  • exec: use command lookup joined with current PATH (d9175e8)

2.0.0 (2017-05-31)

Bug Fixes

  • npm: manually look up npm path for Windows compat (0fe8fbf)

Features

BREAKING CHANGES

  • commands: If a command has an explicit --package option, or if the command has an @version part, any version of the command in $PATH will be ignored and a regular install will be executed.

1.1.1 (2017-05-30)

Bug Fixes

  • docs: make sure man page gets installed (2aadc16)

1.1.0 (2017-05-30)

Bug Fixes

  • help: update usage string for help (0747cff)
  • main: exit if no package was parsed (cdb579d)
  • opts: allow -- to prevent further parsing (db7a0e4)

Features

  • updates: added update-notifier (8dc91d4)

1.0.2 (2017-05-30)

Bug Fixes

  • pkg: bundle deps to guarantee global install precision (3e21217)

1.0.1 (2017-05-30)

Bug Fixes

  • build: add dummy test file to let things build (6199eb6)
  • docs: fix arg documentation in readme/manpage (d1cf44c)
  • opts: add --version/-v (2633a0e)

1.0.0 (2017-05-30)

Features

  • npx: initial working implementation (a83a67d)