I think I’ve been using npm incorrectly, most of the time installing globally (with -g) instead of locally (with -save). Now I have a long list of global packages that I want/ought** to clean up.
(**I’m new to this, and in addition to being OCD-tidy, I don’t want to accidentally use a package in an app without explicitly mentioning it, otherwise it might become a tough puzzle to deploy someplace.).
I understand that I can use
npm uninstall <package> -g to do the actual removal, but how do I decide what should stay? There’s a looong list of things named like “[email protected]” and so on.
Is there a way to determine if a project is using it, or if its the kind of thing I need globally? It will be a long day going to the docs for each one. Or maybe there’s a rule of thumb, like: “one typically needs x, y, and z, and you can delete the rest”?
Also, once I have a removal list, is my only choice to execute all of those unistall -g commands one by one?
You can use:
npm uninstall -g package_to_uninstall
If you prefer video: https://docs.npmjs.com/getting-started/uninstalling-global-packages
If you want to remove all packages; There is trick: Please follow below link:
Command to remove all npm modules globally?