• This repository has been archived on 06/Jul/2019
  • Stars
    star
    2,625
  • Rank 17,445 (Top 0.4 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 7 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

execute npm package binaries (moved)

npm license Travis AppVeyor Coverage Status

npx(1) -- execute npm package binaries

NOTE: This repo has moved to https://github.com/npm/npx.

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'
...
 _____
< [email protected] >
 -----
        \   ^__^
         \  (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)

More Repositories

1

miette

Fancy extension for std::error::Error with pretty, detailed diagnostic printing.
Rust
2,005
star
2

big-brain

Utility AI library for the Bevy game engine
Rust
1,032
star
3

cacache-rs

A high-performance, concurrent, content-addressable disk cache, with support for both sync and async APIs. 💩💵 but for your 🦀
Rust
529
star
4

cipm

standalone ci-oriented package installer for npm projects (moved)
JavaScript
400
star
5

make-fetch-happen

Get in loser, we're making requests!
JavaScript
384
star
6

pacote

programmatic npm package and metadata downloader (moved!)
JavaScript
280
star
7

cacache

💩💵 but for your data. If you've got the hash, we've got the cache ™ (moved)
JavaScript
240
star
8

chanl

Portable channel-based concurrency for Common Lisp
Common Lisp
164
star
9

mona

Composable parsing for JavaScript
JavaScript
152
star
10

rust-notes

Personal notes while learning Rust. Mainly documenting pain points along the way.
145
star
11

maybe-hugs

Polyglot implementations of conditional hugging
OCaml
114
star
12

proposal-as-patterns

`as` destructuring patterns
105
star
13

sheeple

Cheeky prototypes for Common Lisp
Common Lisp
99
star
14

pattycake

playground for pattern matching api
JavaScript
98
star
15

ssri

Standard Subresource Integrity library for Node.js
JavaScript
82
star
16

json-parse-better-errors

get better errors
JavaScript
67
star
17

squirl

Common Lisp port of the Chipmunk 2d physics library
Common Lisp
53
star
18

supports-color

Detects whether a terminal supports color, and gives details about that support
Rust
42
star
19

figgy-pudding

Cascading, controlled-visibility options object management.
JavaScript
39
star
20

genfun

Prototype-friendly multimethods for JavaScript.
JavaScript
38
star
21

ssri-rs

Rusty implementation of Subresource Integrity
Rust
38
star
22

can.viewify

require() mustache and ejs modules as compiled CanJS views
JavaScript
37
star
23

protoduck

Duck typing for the most serious of ducks.
JavaScript
35
star
24

chillax

CouchDB abstraction layer for Common Lisp
Common Lisp
34
star
25

cl-openal

Common Lisp bindings for the OpenAL audio library.
Common Lisp
34
star
26

conserv

Common Lisp
31
star
27

memento-mori

Robustness through actors, for Common Lisp
Common Lisp
31
star
28

talks

Notes and slides for all my talks
JavaScript
26
star
29

until-it-dies

A batteries-included game engine.
Common Lisp
25
star
30

supports-hyperlinks

Detect whether the current terminal supports rendering hyperlinks
Rust
25
star
31

matrix-curious

FAQ and resources for those curious about joining the Matrix network!
23
star
32

sykobot

An IRC bot from another universe. No, really.
Common Lisp
21
star
33

turron

Rusty NuGet client
Rust
20
star
34

npm-pick-manifest

Standard manifest picker/semver resolver for npm
JavaScript
20
star
35

cl-ffmpeg

CFFI bindings for FFMPEG
Common Lisp
19
star
36

proposal-collection-literals

[WITHDRAWN] tc39 proposal for custom collection literals
18
star
37

cl-devil

Common Lisp bindings for DevIL
Common Lisp
16
star
38

okimdone

tells you when it's done
Shell
15
star
39

srisum-rs

Compute and check subresource integrity digests.
Rust
14
star
40

thisdiagnostic

Add nice user-facing diagnostics to your errors without being weird about it.
Rust
14
star
41

is_ci

Super lightweight and dead-simple CI detection.
Rust
12
star
42

common-worm

A simple, hackish version of the classic snake game, written in Common Lisp
Common Lisp
12
star
43

supports-unicode

Detects whether a terminal supports unicode.
Rust
12
star
44

nanotubes

Fancy websocket wrapper for Rust
Rust
12
star
45

srisum

Compute and check Subresource Integrity digests.
JavaScript
11
star
46

DWG.Directories

Standard directories for .NET
10
star
47

cadr

content-addressable filesystem snapshots
JavaScript
10
star
48

protocols

Multi-type protocol-based polymorphism
JavaScript
10
star
49

cl-speedy-queue

Lightweight, optimized queue implementation for CL
Common Lisp
9
star
50

playwright

Like Erlang, but not
JavaScript
9
star
51

sykosomatic

Cooperative storytelling
Common Lisp
7
star
52

cond

Restartable error handling system for JavaScript
JavaScript
7
star
53

destealify

Browserify transform for processing StealJS modules
JavaScript
7
star
54

bacon-browser

Utility library for higher-level, declarative interaction with various bits of browser-level events and features.
JavaScript
7
star
55

sykosomatic-legacy

text-based online game engine
Common Lisp
7
star
56

shepherdb

A Sheeple-based persistent object store.
Common Lisp
6
star
57

clutter

nothing to see here
Common Lisp
6
star
58

facile

CouchDB view server for Factor
Factor
6
star
59

fl-protocols

fantasy-land specification bridge for @zkat/protocols
JavaScript
6
star
60

electron-collider

Rust
5
star
61

my-precious

a local package archive, of our own
JavaScript
5
star
62

checksum-stream

Calculates and/or checks data coming through a stream and emits the digest before stream end.
JavaScript
5
star
63

cl-form

Generic form validation utility for CL
Common Lisp
5
star
64

common-brick

Breakout clone with "realistic" physics.
Common Lisp
4
star
65

surf-middleware-cache

http caching middleware for the Surf http client
Rust
4
star
66

specificity

Runnable specifications for Common Lisp
4
star
67

friendfavor

Find out what your friends think of something -- or someone!
Common Lisp
4
star
68

shortening

The personal URL shortener.
Common Lisp
3
star
69

kallisti

kallisti
Rust
3
star
70

clutterscript

Pay this no heed, I'm just learning stuff.
JavaScript
3
star
71

cl-event2

libevent2 bindings for Common Lisp
Common Lisp
3
star
72

yashmup

Toy project -- writing a shmup in CL
Common Lisp
3
star
73

test

just a place to test random github shit
2
star
74

marina

placeholder for programming language
2
star
75

mona-csv

simple mona-based csv parser
JavaScript
1
star
76

proto

Alternative to JavaScript's `new`.
Makefile
1
star
77

dynvar

Dynamic variables for JS
JavaScript
1
star
78

protoduck-fl

fantasy-land specification bridge for protoduck
JavaScript
1
star
79

mona-json

mona-based JSON parser
JavaScript
1
star
80

mona-strings

String parsers for mona
JavaScript
1
star
81

logloc

Adds source location to console loggers
JavaScript
1
star
82

zkat

it me
1
star
83

node-otp

The Node.js Open Telecom Platform
1
star
84

fetch-cache

Cache API implementation + protocol
JavaScript
1
star
85

tswrp

JavaScript
1
star
86

chownr-rs

Like chown -r for Rust
Rust
1
star
87

presentations

various presentations
JavaScript
1
star
88

storychat

~~~ tell me a story <3 with your words ~~~
JavaScript
1
star
89

mona-combinators

Parser combinators for mona
JavaScript
1
star
90

fig-roll

rolls up your configs into a nice figgy pudding
1
star
91

chatoid

Toy chatroom using webrtc
JavaScript
1
star
92

ironsworn-mechanics

Various support utilities and some custom rendering for mechanics in Ironsworn-family games (Starforged, Sundered Isles, etc).
TypeScript
1
star
93

zkat.github.io

Web sight
TypeScript
1
star