What is npx and How to Use It
No, it's not a typo of npm.
It's a separate tool bundled with npm version 5.2.0 and higher, providing a handy way to execute Node.js binaries.
What is npx?
npx allows developers to run commands from locally installed packages without globally installing them.
This promotes a more efficient workflow and cleaner global space.
A few years ago it would be pretty normal to globally install tools on your system before running them.
The magic of
npx comes from its ability to run packages that aren't globally installed on your system.
If you attempt to run a package using
npx that isn't installed locally,
npx will temporarily install and run that package.
How to Use npx
npx is incredibly simple, and I guess that is why JS devs love it. Here's how:
1. Run npx:
In the example above,
npx will either run
create-next-app if it is installed or fetch it from the npm registry and run it.
Simple, right? 🚀
2. Specifying a Package Version:
In this example, you can pick a specific version in the same way you would if you were using
🚨 Want to make friends and learn from peers? You can join our free web developer community here. 🎉