在尝试删除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.

其他回答

因为这是谷歌的结果,这是对我有用的:

更新,如果你有npm v5,使用npx:

- npx rimraf . - **/ node_模块

否则安装RimRaf:

NPM安装rimraf

在项目文件夹中删除node_modules文件夹:

rimraf node_modules

如果你想递归删除:

rimraf \ * * \ node_modules

[http://www.nikola-breznjak.com/blog/nodejs/how-to-delete-node_modules-folder-on-windows-machine/]

我用giitbash删除文件夹!

rm -r node_modules

我花了一些时间删除所有内容,但对我来说很有效!

在Windows平台上,最简单的方法是使用终端。 请执行命令RMDIR /Q/S foldername删除该文件夹及其所有子文件夹。

例如:RMDIR /Q/S node_modules

上面的命令删除node_modules文件夹及其子文件夹。 有关信息,请访问https://www.ghacks.net/2017/07/18/how-to-delete-large-folders-in-windows-super-fast/

这太简单了。

只需删除node_modules中的所有文件夹,然后删除实际的node_module文件夹。

这对我有用。最好的运气……

在Windows上,使用Total Commander,你所要做的就是选择文件夹,点击shift + delete。别忘了shift键。