命令全局删除所有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版本,请参见奥利·贝内特的答案.
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屋!
查看全文