Next JS:错误:EPERM:操作不允许,rmdir

6

我有一个Next.js应用程序,它能够正常工作,但是当我离开它并返回时,会出现以下问题:

  errno: -4048,
  code: 'EPERM',
  syscall: 'rmdir',
  path: 'C:\\Users\\gmacr\\Google Drive\\Optical-Font-Website\\O\\.next\\server\\pages'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opt@0.1.0 dev: `next dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opt@0.1.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\gmacr\AppData\Roaming\npm-cache\_logs\2021-10-16T21_14_26_886Z-debug.log 

我尝试使用npm clean cache。我使用的是Windows 10操作系统。当我创建一个新的Next应用程序并将我的工作文件复制到其中时,该程序在没有错误的情况下运行,但是当我离开一段时间后再回来,就会出现问题...


1
“当我离开它并回来时”是什么意思?您能描述一下导致错误发生的具体步骤吗? - juliomalves
1个回答

10

当项目目录在“谷歌云端硬盘”中时,会发生这种情况!

您需要做的就是删除“.next”目录。

或者添加一个脚本到package.json中以删除它(已在Windows 10上进行测试):

 "scripts": {
    "dev": "(if exist .next rd /s /q .next 2>nul) && next dev",
},

太好了!退出Google Drive成功了。只是为了澄清,您是说如果我删除.next或编写脚本,我可以将其保留在驱动器中吗? - George M
1
嗨@GeorgeM!是的,只要您每次启动服务器时手动删除.next目录(这就是脚本所做的),您可以将其保留在驱动器中。我也将我的项目放在驱动器内,我创建了一个脚本将node_modules保持在外部(避免大量不必要的同步),请看这里:https://github.com/lobobruno/googledrive-nodemodules-ignore/blob/master/link-nodemodules.bat - Bruno Lobo
等一下…为什么要使用Drive而不是GIT + Github? - LukeSavefrogs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接