下一个 JS:错误:EPERM:不允许操作,rmdir

Geo*_*e M 6 windows node.js npm reactjs next.js

我有一个可以运行的 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 
Run Code Online (Sandbox Code Playgroud)

我尝试使用 npm clean 缓存。使用 Windows 10。当我创建一个新的 Next 应用程序并复制我的工作文件时,程序运行时没有错误,直到我离开它一段时间并返回它......

Bru*_*obo 10

当项目目录位于“Google Drive”内时,就会发生这种情况!

您所要做的就是删除“.next"目录。

或者在package.json中添加一个脚本来删除它(windows 10测试过):

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