是否有删除所有全局npm模块的命令?如果没有,你有什么建议?


当前回答

npm list -g

将显示全局安装包的位置。

如果你想把它们输出到一个文件: npm list -g > ~/Desktop/npmoutputs.txt

npm rm -g

会移除它们

其他回答

好吧,如果你在windows上,想要删除/卸载所有的node_modules,那么你需要执行以下步骤。

进入windows命令提示符 导航到node_modules目录(不在node_modules文件夹内) 输入下面的命令,并给它1-2分钟,它将卸载node_module中的所有目录 Rmdir /s /q node_modules .使用实例

希望这对窗户上的人有所帮助

如果你想删除你已经安装的所有包,你可以使用npm -g ls命令找到它们,然后npm -g rm删除它们。

npm ls -gp | awk -F/ '/node_modules/&&!/node_modules.*node_modules/&&!/npm/{print $NF}' | xargs npm rm -g

对于使用Powershell的用户:

npm -gp ls --depth=0 | ForEach-Object { Get-Item $_ } | Where { $_.Name -ne 'npm' } | ForEach-Object { npm rm -g $_.Name }

清除缓存。

npm cache clear

Windows:

rmdir /s /q "%appdata%/npm"