npm command to uninstall or prune unused packages in Node.js
问题 Is there a way to simply uninstall all unused(undeclared) dependencies from a Node.js project (ones that are no longer defined in my package.json .) When I update my application I like to have the unreferenced packages removed automatically. 回答1: Run npm prune to remove modules not listed in package.json . From npm help prune : This command removes "extraneous" packages. If a package name is provided, then only packages matching one of the supplied names are removed. Extraneous packages are