Engineering / Can you explain the difference between npm and npx?

1.6K WORDS · KOHTA KOUCHI

Can you explain the difference between npm and npx?

I kept typing both to spin up localhost without really knowing why — so I dug in.

FIG · 1 · 2026.02

While learning front-end development at university, I kept reaching for both npm and npx to spin up a localhost without ever being able to say what actually separated them. That nagging gap felt worth closing, so I sat down and worked it out properly.

npm — node package manager — ships with Node.js and manages your dependencies: the packages a project depends on, tracked and installed into the node_modules folder. It's the thing that turns a package.json into a working set of libraries on disk.

npx — node package executer, bundled since npm 5.2.0 — runs packages. Its trick is that it can execute a package you haven't installed: it finds it, installs it, runs it, then cleans up after itself. So instead of adding a tool to package.json's scripts or going through node_modules/.bin, you just run something like `npx vue create my-app` and npx resolves the dependencies for you on the spot.

Worth a mention alongside them is yarn, the JavaScript package manager Facebook released in 2016 — an alternative to npm that installs faster and pins versions more strictly.

The real takeaway wasn't the definitions. It was that questioning a command I used on autopilot every day led me to actually understand the machinery underneath it — and that's a habit I want to keep: when a line of 'boilerplate' makes me wonder, go look it up.