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?
If you would like to remove all the packages that you have installed, you can use the npm -g ls command to find them, and then npm -g rm to remove them.
If you want to uninstall all global packages, then you need to name the packages one by one in the npm uninstall -g command. Run the npm list -g --depth=0 command to list the packages installed globally on your computer. That should uninstall all global packages for you.
To uninstall an unscoped global package, on the command line, use the uninstall command with the -g flag. Include the scope if the package is scoped.
How does npm install packages globally? Global modules are installed in the /usr/local/lib/node_modules project directory in the standard system, which is the system's root. Print the location of all global modules on your system using this command.
You can use: npm uninstall -g package_to_uninstall
See:https://docs.npmjs.com/cli/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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With