Difference between npm and npx

Hi All,

Since, we are working on frontend technologies, we might get this question early or later stage of our working experience.

What is the difference between npm and npx.

Before getting into the difference, let's discuss what is npm and npx.

NPM stands for Node Package Manager, which is used to install packages from node repository into your local machine.


Since, in above example, I just installed json-server package. I want to execute this package in my local system.

 For that purpose, I need to execute one more command as below :




NPX stands for Node Package Execute, which is used to execute package from node repository into your local machine.


Now, let's see the difference or in other words, let's discuss about when can we use npm and when can we use npx.

Scenario is, when you just want to execute the package, and not required to install in your local system. You can use npx command, it will execute your package directly by looking into node repository over web. First, it will look into local system, if package is installed or not, otherwise it will execute directly from node repository over web.

And, if you need to get the package into your local system for further requirement fulfilling, you can use npm command to install that particular package.

Another example is for all the react developers.
To create a new boilerplate code project for react, we can use 'create-react-app' package.

There is also two steps, if we first install and then execute that package. Otherwise, we can directly use npx to create CRA(create-react-app) project in our local system.

NPM : 



NPX :


Thanks for reading this article.

Hope this article helps you understand the difference between npm and npx.
Stay tuned for more articles!!!







Comments

Popular posts from this blog

Why Axios for API integration