简体   繁体   中英

How to Remove Installed npm packages globally?

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 "cuddly-bunny@1.2.3" 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

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?

这在 ubuntu for pm2 上不起作用,我不得不运行npm remove pm2 -g

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM