[英]npm uninstall removes the package from package.json but doesn't remove it from node_modules folder
[英]How to remove unwanted packages from node_modules? npm rm doesn't work
我一辈子都想不出一种从 node_modules 中删除包的简单方法。
我正在关注一个教程,它告诉我使用npm rm <pkg>
,但是当我验证我正确执行了操作时,它说依赖关系仍然存在。 我查看了我的根目录并注意到虽然 package.json 中删除了 package,但它仍然存在于我的 node_modules 目录中。 为什么npm rm <pkg>
实际上没有像我想象的那样删除 package ? 另一种解决方案是什么? 我想我可以完全删除我的 node_modules 目录,但如果我有其他依赖项/包,那将无法正常工作。
我试过用谷歌搜索答案,但奇怪的是什么都没出现。
npm uninstall
会从 node_modules 中删除模块,但不会从 package.json 中删除。
npm uninstall
--save 以同时删除 package.json 的依赖项。
npm rm <pkg>
在卸载不起作用时删除软件包
npm prune <pkg>
用于无关包
如果不想一一卸载运行
rm -rf pkg-name && npm cache clean && npm install
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.