全局删除所有 npm 模块的命令 [英] Command to remove all npm modules globally
本文介绍了全局删除所有 npm 模块的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有删除所有全局 npm 模块的命令?如果没有,您有什么建议?
Is there a command to remove all global npm modules? If not, what do you suggest?
推荐答案
以下命令删除所有全局 npm 模块.注意:这不适用于 Windows.有关可用的 Windows 版本,请参阅Ollie Bennett 的回答.
The following command removes all global npm modules. Note: this does not work on Windows. For a working Windows version, see Ollie Bennett's Answer.
npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !//npm$/ {print $NF}' | xargs npm -g rm
这是它的工作原理:
npm ls -gp --depth=0
列出所有全局顶级模块(请参阅 ls 的 cli 文档)awk -F/'/node_modules/&&!//npm$/{print $NF}'
打印所有实际上不是 npm 本身的模块(不以/npm
结尾)xargs npm -g rm
全局删除来自前一个管道的所有模块
npm ls -gp --depth=0
lists all global top level modules (see the cli documentation for ls)awk -F/ '/node_modules/ && !//npm$/ {print $NF}'
prints all modules that are not actually npm itself (does not end with/npm
)xargs npm -g rm
removes all modules globally that come over the previous pipe
这篇关于全局删除所有 npm 模块的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文