DEV Community

Maggie DeSantis
Maggie DeSantis

Posted on • Updated on

NPM vs NPX

I recently came into a problem trying to install a JSON server globally and came up with error after error and unable to install it. Today while working in visual code on a project for school, I finally found a solution that now works for most of my json-server needed projects.

NPM vs NPX

So, what are they and how do they differ? Well, npm (short for Node Package Manager) is a command-line tool used to manage Node.js packages and dependencies. It allows you to install, update, and remove packages in your project. On the other hand, npx is a tool that comes with npm and is used to execute packages without having to install them globally on your system. This means that you can run a package directly from the command line without worrying about installing it first. In other words, npx is like a one-time use version of npm. So, if you need to use a package just once or for a specific task, you can use npx. But if you need to use a package more frequently or across multiple projects, it's best to use npm to install and manage it.

3/100

edit I'm going to add onto this blog by posting the solution I found for this error I kept getting:

cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?
Enter fullscreen mode Exit fullscreen mode

to enable scripts while using powershell in VSC I had to open powershell in admin mode.
type in

Set-ExecutionPolicy RemoteSigned
Enter fullscreen mode Exit fullscreen mode

and the Y to change script permissions.
restart your VScode and you're ready to go!

Top comments (0)