gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 12:10:27 25 4
gpt4 key购买 nike

我试图通过使用删除包

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 yourpackage.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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com