What is npx???đđđ


Ah, npxâthe Swiss Army knife of the Node.js world. Itâs like that one friend who always seems to have exactly what you need at the exact moment you need it.
Included with npm starting from version 5.2.0, npx lets you run Node.js tools like Jest, Mocha, or ESLint without the hassle of installing them globally. Think of it as your on-demand butler for Node.js binaries.
Why Use npx?
1. Avoid Global Installations:
Normally, youâd install tools like Jest or ESLint globallyâkind of like turning your whole house into a storage unit just to store a single wrench. But with npx, you donât have to clutter your global space! Itâll run the local version of a tool (if itâs already in your project) or temporarily download it for you faster than you can say, ânpm who?â
2. Execute Local Project Tools:
When you install Jest locally (npm install jest --save-dev
), it takes up residence in your node_modules
folder like a polite houseguest. npx ensures it uses this local version instead of waking up a global one and risking, âWait, why is this behaving differently here?â vibes.
3. One-Time Use:
Need a tool but donât want to commit to it like itâs a long-term relationship? Just use npx! For instance:
npx create-react-app my-app
It downloads, uses, and then lets goâlike the perfect fling.
How npx Works with Jest
If youâve installed Jest locally with:
npm install jest --save-dev
You can run:
npx jest
Boom! Local Jest at your service. If you havenât installed it, npx will fetch it for you, like DoorDash for dev tools.
Key Differences: npm vs npx
Feature | npm | npx |
Installing Tools | Installs globally or locally. | Skips installation; runs directly. |
Running Tools | Needs npm run for local tools (ugh). | Directly runs tools like a boss. |
Flexibility | Only works with installed tools. | Runs anything, installed or not. |
Examples of Using npx
Run Jest:
npx jest
Itâs like, âWho needs commitment? Just run the tests.â
Run ESLint:
npx eslint yourFile.js
Because clean code is a lifestyle, not a suggestion.
Create a React App:
npx create-react-app my-app
Skip the awkward global install phase. Just spin up your app and go!
Why Is Everyone Obsessed with npx?
Developers these days are all about keeping things lightweight and avoiding unnecessary global installsâlike Marie Kondo but for dev environments. Tools are usually installed per project, and npx ensures youâre always using the correct local version. Itâs simple, itâs fast, and itâs here to keep your dev life drama-free.
So, next time you see a bunch of npx commands, just think of it as the Uber of Node.js tools: always available, always reliable, and never overstaying its welcome.
Subscribe to my newsletter
Read articles from Maneeshwar Karne directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Maneeshwar Karne
Maneeshwar Karne
Learning web devlelopment