在尝试删除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.
其他回答
NPM install -g remove-node-modules CD到根目录并删除节点模块 或删除节点模块路径/到/文件夹
来源:
https://github.com/j-quelly/node-cleanup
在Windows上,我的解决方案是使用rmdir命令:
rd /S .\node_modules\
如果第一次失败了,那就再试一次。 还要检查当前是否有正在运行的脚本使用这些模块(npm run serve或类似的)。
删除深网文件夹,如Windows中的node_modules
选项1 使用rimraf NPM包删除 打开命令提示符并将目录更改为所在的文件夹 存在Node_modules文件夹。 运行 rimraf node_modules 缺少rimraf错误,然后安装 NPM安装rimraf 安装完成后,运行 rimraf node_modules 选项2: Detele没有安装任何东西 在任意驱动器中创建名为test的文件夹 robocopy /MIR c:\test D:\UserData\FolderToDelete > NUL 删除文件夹test和FolderToDelete,因为它们都是空的
为什么这在windows中是一个问题?
其中一个深度嵌套的文件夹结构是node_modules, Windows无法删除该文件夹,因为它的名称太长。要解决这个问题,简单的解决方案,安装一个节点模块RimRaf
使用CMD命令
npx rimraf node_modules
PowerShell方式:
PS > rm -r -force node_modules
# The same, but without using aliases
PS > Remove-Item -Recurse -Force node_modules
如果你想删除子目录中的所有node_modules:
注意递归删除的潜在危险,请确保您在这里所做的事情
PS > dir -Path . -Filter node_modules -recurse | foreach {echo $_.fullname; rm -r -Force $_.fullname}