npx [--package|-p <package>] [--cache <path>] [--save-dev|-D] [--save-prod|-P] [--save-optional|-O] [--save-bundle|-B] [--save-exact|-E] [--global|-g] [--prefix|-C] [--userconfig <path>] [-c <string>] [--version|-v] [--] <command>[@version] [command-arg]...
npm install -g npx
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, <command> will be installed prior to execution. An optional @version may be appended to specify the package version required.
-
-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@versionif it's there. -
--cache <path>- set the location of the npm cache. Defaults to npm's own cache settings. -
-g, --global- install the package globally before execution. -
-D, --save-dev, -P, --save-prod, -O, --save-optional, -B, --save-bundle, -E, --save-exact- install the package in the current npm project and save it topackage.jsonfollowing the same option conventions for this asnpm installwould. -
-C, --prefix- The location to install global items. If used without-g, will force any installs to run in the specified folder. Defaults to whatever npm's default is. -
--userconfig- path to the user configuration file to pass to npm. Defaults to whatever npm's current default is. -
-c <string>- Execute<string>with delayed environment variable evaluation. -
-v, --version- Show the current npx version.
$ npm i -D webpack
$ npx webpack -- ...
$ npm rm webpack
$ npx webpack -- ...
$ cat package.json
...webpack not in "devDependencies"...
$ npx -D webpack -- ...
$ cat package.json
...webpack added to "devDependencies"
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.
Written by Kat Marchan.
Please file any relevant issues on Github.
This work is released by its authors into the public domain under CC0-1.0. See LICENSE.md for details.
npm(1)npm-run-script(1)npm-config(7)