在尝试删除npm install创建的node_modules目录时:
源文件名大于该文件支持的文件名 系统。尝试移动到路径名称较短的位置,或者尝试 在尝试此操作之前,将名称重命名为较短的名称
我也尝试了shift + delete,仍然有同样的问题。
在尝试删除npm install创建的node_modules目录时:
源文件名大于该文件支持的文件名 系统。尝试移动到路径名称较短的位置,或者尝试 在尝试此操作之前,将名称重命名为较短的名称
我也尝试了shift + delete,仍然有同样的问题。
当前回答
我使用的一个解决方案是:
(我更倾向于在使用CI环境时避免安装新的扩展(rimraf)。)
A) Rename packages.json to something else. B) Specially on CI - after npm install, I usually remove the file instead of renaming it, but if you need it, you don't have to do this. That's your choice. run npm init - this will create an empty packages.json file (no dependencies) run npm prune - this will match node_modules with the dependencies section of packages.json - which is now empty as the result of step #2. If you have chosen #1.A. step, delete the newly created packages.json, and rename original packages.json back to its original name.
其他回答
在Windows上,使用Total Commander,你所要做的就是选择文件夹,点击shift + delete。别忘了shift键。
为了备份,我需要清理整个Projects目录,所以我安装了rimraf并在根目录下运行(在git bash提示符中):
find . -name "node_modules" -type d -prune -exec rimraf '{}' +
非常有效,真正的递归(避免子node_modules),在windows上快速(感谢rimraf)。
来源:
https://rtmccormick.com/2018/01/10/clear-node-modules-folders-recursively-mac-linux/ 这个问题的公认答案暗示了rimraf,但在递归方面缺乏
尝试Visual Studio代码
在尝试了许多解决方案后,我发现这是相当简单的。 只需在Visual code中打开项目并删除它。UI可能会冻结几秒钟,但它肯定会工作。我使用许多大尺寸的node_modules文件夹进行测试
谢谢
任何文件管理器都可以避免这样的问题,例如Far manager
这太简单了。
只需删除node_modules中的所有文件夹,然后删除实际的node_module文件夹。
这对我有用。最好的运气……