node.js - npm uninstall 从 package.json 中删除包,但不会从 node_modules 文件夹中删除

标签 node.js angular npm angular5

我试图通过使用删除包

npm uninstall (package_name) -s 
哪个从 package.json 中删除了包但没有从 node_modules 文件夹中删除它,那么如何从 node_modules 文件夹中删除这些未使用的包?
编辑:
我正在分享这个问答,因为我个人遇到了这个问题,使用了 npm uninstall 的所有变体但它没有从 node_modules 中删除包,所以我分享了帮助我删除大约 10 个未使用的包的内容,即 npm prune

最佳答案

As per the npm guide , npm uninstall 仅从依赖项中删除包,它不会从 node_modules 中删除包文件夹(无论如何在描述中都没有提到)
出于某种原因,我认为 npm uninstall 也会从 node_modules 中删除包文件夹,但它没有发生,经过一些研究我发现我们应该使用

npm prune
此命令将根据 the official npm description 自动从 node_modules 中删除未使用的包

that the npm uninstall will only remove the package from your package.json file but it will not delete the package from your node_modules

关于node.js - npm uninstall 从 package.json 中删除包,但不会从 node_modules 文件夹中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51274695/

相关文章:

node.js - 结束对话

javascript - Isotope.js 和 Webpack - 可能吗?

javascript - 无法从一个js调用函数到第二个函数

angular - Material 2.0.0-beta.3 md-slider 不拖动

Angular 如何延迟/错开子组件内部的动画

node.js - 如果 npm 测试失败,npm posttest 不会触发

node.js - strapi 开始 : "url is not defined" - using mlab mongo DB

css - 如何在 laravel 中改变 appcss 的值

javascript - 如何处理从express服务器发送的ajax post响应?

node.js - 显示最近发布的 npm 包版本,包括 beta 版本