Many times, we keep installed packages that we don't use, whether in a project or globally. In this tutorial, you will learn how to uninstall npm packages effectively.
Uninstalling Dependencies with npm uninstall
To remove npm packages that have been installed using the npm install command, you simply need to navigate to the root of your project and execute the following command.
npm uninstall <name-package>
Removing npm Development Dependencies
If the installed package was added as a development dependency using the -D flag, it would be removed as follows:
npm uninstall -D <name-package>
Removing Global npm Packages
If the package was installed globally, you should use the -g flag, and in this case, you can do it from any file.
npm uninstall -g <name-package>