TLDR: What Is Npx? How Does It Differ From Npm?

TLDR: What Is Npx? How Does It Differ From Npm?

If you’re currently or aspiring to be a node.js developer, knowing the difference between npx and npm is essential.

If you’re currently or aspiring to be a node.js developer, knowing the difference between npx and npm is essential.

If you’re reading this article you’re probably already familiar already with what npm is. For those that are not, npm is simply a package manager — a CLI tool that allows us to install and use various packages of code from the Node library. Npm can do much more than this but, for simplicity's sake, we can just think of it as allowing us to download and run packages locally within our projects.

Npx is very similar to npm, but differs in a fundamental way -

Npm is a tool used to install Node packages.

Npx is a tool used to execute Node packages.

It really is as simple as that. Npm is used to locally download packages, which can execute (again locally) when we desire. Npx is used to execute packages without having to install and run them locally. Npx is extremely useful for reducing package pollution — we don’t want to locally install packages that we may only need to execute once.

A practical example of this in the Node package create-react-app , which if you develop with React you will be gruelingly familiar with. This package is used to set up a new React project, so it typically executed only once right at the start of a project. Therefore we don’t want to install it globally as we are not going to use it more than once! (Facebook themselves say to use npx over npm for create-react-app )

With npm:

npm install create-react-app //installs globally, not needed!

create-react-app newApp //executing the package

With npx:

npx create-react-app newApp //executing the package, no install

We are still able to pass command-line arguments to the package when using npx, it functions exactly like executing from the CLI locally.

web-development javascript react nodejs

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Hire NodeJs Developer

Looking to build dynamic, extensively featured, and full-fledged web applications? **[Hire NodeJs Developer](https://hourlydeveloper.io/hire-dedicated-node-js-developer/ "Hire NodeJs Developer")** to create a real-time, faster, and scalable...

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms? React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. **[Hire...

Hire Dedicated React Native Developer in India | React Native Development

Hire dedicated React Native developers for your next project. As the top react native development company we offer you the best service as per your business needs.

Architecting a Progressive Web App using React Native: Step by Step Guidance!

![This is image title](https://miro.medium.com/max/875/1*GUJAmsfuQbokFMBL3aUm7Q.jpeg "This is image title") A Progressive Web Application (PWA) is a disruptive innovation that integrates the functionality of a native mobile app and the usability...