【发布时间】:2016-12-25 06:07:59
【问题描述】:
我有一个非常复杂的项目,它有依赖项和子依赖项。我的项目中有 git 子模块,其中有 npm 依赖项。
有没有一种快速有效的方法来递归地清理我项目中的所有node_modules 文件夹?
【问题讨论】:
标签: node.js recursion npm uninstallation
我有一个非常复杂的项目,它有依赖项和子依赖项。我的项目中有 git 子模块,其中有 npm 依赖项。
有没有一种快速有效的方法来递归地清理我项目中的所有node_modules 文件夹?
【问题讨论】:
标签: node.js recursion npm uninstallation
只需在 package.json 文件中清除所有要删除的依赖项,然后运行 npm prune。
【讨论】:
git 子模块,其中包含 npm 依赖项。在最高级别上,您所说的会起作用,或者我可以删除我的node_modules 文件夹。但这不会影响我的子模块
如果您要问如何摆脱 node_modules 的嵌套混乱,有几种方法可以做到这一点:
rimraf,然后调用rimraf [directory-path]
【讨论】:
如果你使用的是unix系统,基本上可以运行这个命令find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
或者使用这个脚本https://gist.github.com/qutek/868c30f5d1e7ec03c7459e067444bd67
只需下载它并使其可执行chmod +x clear-node-modules.sh 并运行它./clear-node-modules.sh
【讨论】: