← Back to Node.js Course | Chapter 3: npm & Packages | Lesson 4 of 7

npx

npx runs a package's command without installing it permanently.

In this page:

  1. npx
Syntax
javascript
npx package_name arguments

npx

npx downloads a package temporarily (or uses a local one) and runs its binary. It is ideal for scaffolding tools like create-react-app or one-off tasks. Local binaries in node_modules/.bin are also found by npx.

Note: Use npx package@version to pin the version you run.

Example: npx

bash
$ npx cowsay "Hello npx"
$ npx eslint .
$ npx create-vite@latest my-app
$ npx --yes serve .

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Assuming npx installs globally
  2. Running untrusted packages blindly
  3. Forgetting the version can change between runs
Chapter Summary
  • npx runs package binaries
  • No permanent install needed
  • Finds local node_modules/.bin tools
  • Pin versions for repeatability
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.