3

So I read that using NPX would be good because, among other things, it would allow me to run packages with no need of installing them. One of the advantages I would get immediately would be more free space on disk. However, when I run something like

npx cowsay mu

it says it must install the package. If I say no, the operation is aborted. If I say yes, it installs the package on its own cache. My NPX cache, for example, can be found at /home/user/.npm/_npx/.

I was expecting this cache to be cleared automatically, which is not the case. It remains there forever. Of course I can delete everything manually, but if I have to do that I cant really how different it is from just, say, install the package normally with npm and once I dont want it anymore I simply uninstall it, again with npm.

Of course, NPX makes it easier to run commands. But as per my considerations, its advantages have nothing to do with free space on disk. Am I correct?

BTW, Im using npm 7+, which included the --yes or --no option when running a package with NPX.

Rodrigo
  • 31
  • 2

1 Answers1

0

This answer should have been a comment (I can’t yet), but yes you’re correct nothing to do with disk space.

npx is intended to run a binary without the need to create a package.json and add a script to execute it.

Check this blog post from npm when npx came out. At the end you’ll have a way to use npx as your shell fallback and omit npx altogether, this feature will not install the packages in the disk unless you use packageName@versionSyntax.

mstrk
  • 81
  • 5