Node.js

npx: Run Any npm Package Without Installing It

npx lets you execute npm tools on demand — no global installs, no version conflicts, no cleanup. Most developers underuse it.

May 8, 2026
3 min read

Technologies Discussed

npmnpxNode.jsCLI

The Old Way

Before npx, scaffolding a project meant:

bash
npm install -g create-react-app
create-react-app my-app

Now you have a globally installed tool that drifts out of date, conflicts with other global installs, and requires manual cleanup. Multiply this by every CLI tool you ever use.

The npx Way

bash
npx create-next-app@latest my-app

npx downloads the package temporarily, runs it, then discards it. Always the latest version (unless you pin one). Zero global pollution.

Practical Examples

bash
# Scaffold projects — always run with latest version
npx create-next-app@latest my-app
npx create-react-app my-app
npx create-vite@latest my-app

# Run a quick HTTP server in any directory npx serve .

# Audit and fix npm packages interactively npx npm-check-updates -u

# Generate a .gitignore for any stack npx gitignore node

# Kill a process on a specific port (mac/linux) npx kill-port 3000

# Check what's taking up disk space in node_modules npx cost-of-modules

Pinning a Specific Version

bash
npx create-next-app@14.0.0 my-app   # pin exact version
npx create-next-app@^14 my-app      # pin major version

Useful when you need to match a team's existing setup or reproduce a specific environment.

Running a Local Binary

npx also runs binaries from your local `node_modules/.bin` — which means you can run project-specific tools without a global install or npm script:

bash
npx tsc --version     # runs TypeScript compiler from local node_modules
npx eslint src/       # runs ESLint from local node_modules
npx prisma migrate dev

Takeaway

Default to `npx` for any one-off CLI tool. Keep global installs reserved for tools you genuinely use across every project and need to be available at all times (like the AWS CLI or a custom internal tool). Everything else — npx.

About the Author

Rajeev Ranjan Sinha is a full-stack engineer with 10+ years of experience building scalable web applications. He specializes in JavaScript/TypeScript, cloud architecture, and system design.

Get more articles like this

Subscribe to my newsletter for in-depth articles, quick tips, and insights on web development.