In this tutorial, we are going to learn about how to clean the extra packages in a node_modules folder that are not present in the package.json file using npm.
To remove the node_modules folder packages that are not present in the package.json file, we can use the
npm prune command followed by the package name.
Here is an example, that removes the
express package from the node_modules folder.
npm prune express
for removing multiple packages use:
npm prune express cors
We can also remove the extra packages by deleting the node_modules folder and reinstall it using the
npm uninstall command.