All cheatsheetsFrontend Development

npx

npx 10+ (shipped with npm)

Quick reference for npx commands: run one-off package binaries, scaffold projects, manage the npx cache, pin versions, and avoid pitfalls with interactive CLIs — with common options and practical examples.

25 commands

Run a one-off binary

npx <pkg>

Download the latest version of `<pkg>` (if not in `node_modules/.bin`) and run its CLI entry, then clean up the temporary cache.

<pkg>@<version> pin; --yes / -y auto-confirm the install prompt; --package <pkg> provide a separate package to put on PATH

npx cowsay hello
npx <pkg>@<version>

Pin the version used for the one-off run. The `@<version>` syntax uses semver ranges or dist-tags just like npm install.

npx create-vite@latest my-app --template vue && npx [email protected] tsc --init
npx -y <pkg>

Skip the confirmation prompt when downloading — required in CI and useful for repeatable shell scripts.

npx -y http-server . -p 8080

Scaffold a project

npx create-vite <name>

Scaffold a Vite app (Vue / React / Svelte / vanilla) — fast scaffolding that doesn't bloat your project with a CLI dependency.

--template vue | react | react-ts | svelte | lit | vanilla | etc.

npx create-vite my-app --template vue-ts
npx create-next-app <name>

Scaffold a Next.js app with the chosen router (App Router or Pages Router), TypeScript flag, ESLint, Tailwind, and `src/` placement.

--typescript; --tailwind; --eslint; --app; --src-dir; --import-alias "@/*"

npx create-next-app@latest my-app --typescript --tailwind --eslint --app --src-dir
npx create-react-app <name>

Scaffold a CRA-style React app (CRA itself is in maintenance, but the binary still works for legacy projects and quick demos).

--template typescript; --use-npm | yarn | pnpm

npx create-react-app my-app --template typescript

Run from local node_modules

npx <bin>

When `<bin>` is already in the current `node_modules/.bin`, npx just executes without fetching anything. The recommended way to run locally installed dev tools.

npx eslint src/ && npx tsc --noEmit && npx vitest run
npx --no-install <bin>

Force npx to fail instead of fetching from the registry — useful in CI to detect missing local dependencies.

npx --no-install eslint src/

GitHub-hosted packages

npx github:user/repo

Run a binary directly from a GitHub repo's `main` branch — handy for one-off test releases.

npx github:user/my-cli-tool --help
npx user/repo#<branch|tag|sha>

Pin to a specific ref of a GitHub repo.

npx user/repo#v1.2.3 --flag
npx gist:<gist-id>

Run a script hosted as a GitHub gist. Useful for shared utilities but mind the security implications — anyone can run any gist.

npx gist:abcd1234efgh5678

Local script

npx <script.js>

Run a single JavaScript file with Node, picking up local `node_modules` for `require`/`import` resolution. Convenience over `node script.js`.

npx ./scripts/seed.ts
npx tsx <script.ts>

Use `tsx` (or `ts-node`) to execute a TypeScript file directly. Requires `tsx` to be locally installed.

npx tsx scripts/migrate.ts --dry-run

Package on PATH

npx --package=<pkg1> --package=<pkg2> <cmd>

Make extra packages available on PATH for the run. Useful when the runner depends on side dependencies that aren't directly `npm install`-ed.

npx --package=typescript --package=@types/node tsc --init

Cache control

npx --clear-cache

Wipe the npx package cache (`~/.npm/_npx` on POSIX, `%LocalAppData%\npm-cache\_npx` on Windows) so the next run re-fetches from the registry.

-y to skip prompts; --no to test fetch

npx --clear-cache && npx -y create-next-app@latest demo
ls ~/.npm/_npx

Inspect cached packages manually — each subdirectory is one resolved specifier with its own `package.json` and `node_modules`.

ls -la ~/.npm/_npx && du -sh ~/.npm/_npx/*

Pin behavior

npx --always

Force npx to fetch from the registry even if a local binary with the same name exists. Useful when you want the latest upstream release regardless of project deps.

-y accept the install prompt automatically

npx --always --package=eslint eslint --version
npx -p <pkg> -c '<cmd>'

Set the working directory and use `<pkg>` on PATH for the single invocation. `<cmd>` runs after install completes.

npx -p [email protected] -c 'tsc --init && tsc'

Interactive CLIs

npx -y <scaffold> <name>

Most modern scaffolds (`create-vite`, `create-next-app`, `create-nuxt-app`) auto-detect when they are launched through `npx -y` and skip the install-confirm prompt.

--typescript / --javascript / --template <name>

npx -y create-nuxt-app my-site

Sandbox flags

npx --shell-auto-fallback <bash|zsh|...>

Override npx's auto-detection of the shell used to run scripts on Windows / unusual POSIX setups.

npx --shell-auto-fallback bash
npx --ignore-scripts

Skip lifecycle scripts (postinstall / preinstall) when npx installs a one-off package. Safer for unfamiliar specs.

npx --ignore-scripts -y some-cli --help

Upgrade a package on the fly

npx --package <pkg>@latest -- <cmd>

Run a command using the latest available version of `<pkg>`, regardless of any local install.

npx --package npm-check-updates -- ncu -i

Inspect

npx --version

Print the npx version (matches the bundled npm).

npx --version
npx --help

List every flag npx accepts.

npx --help

Alternatives

npm exec -- <pkg> [args]

Modern npm equivalent of `npx <pkg>`. `npm exec` accepts the same arguments and is recommended over `npx` in some npm docs, but `npx` is shorter and ubiquitous.

--package <pkg>; --yes / -y; --call=<cmd>; --workspaces

npm exec -- create-vite@latest demo --template vue

Related command cheatsheets

About npx

npx is a package runner that ships with npm (since npm 5.2 / 2017) and Node.js (since 7.0+). It locates a command either in `node_modules/.bin` (so it always matches the version installed in your project), or — if not found — fetches the package from the npm registry into a temporary cache (`~/.npm/_npx`) and runs it once, then cleans up. The current npx ships with npm 10. npx is the right way to run scaffolding tools (`create-react-app`, `create-next-app`, `create-vite`) without polluting your project dependencies. npx also accepts GitHub-style specifiers (`github:user/repo`, `user/repo`) and GitHub gists. As of npm 7+, `npx` is mostly a wrapper around `npm exec --` (which was deprecated for a while and brought back). npx never sends your source code anywhere — it only downloads from the registry. The npm registry does record aggregate download counts visible at `npmjs.com`. npx is recommended over manual global installs because it always runs the latest or the explicitly-pinned version without conflicting with your project's local toolchain.

Cheatsheet version 1.0.0