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

MOH*_*QUE 14 deployment cpanel reactjs next.js

我正在尝试构建下一个 Js 应用程序生产文件以将其部署在 cPanel 上,当我执行 npm run dev应用程序时工作正常,但当我开始借助此视频(https://youtu.be/ 1ykSXau838c)并执行npm run build它在终端中给出一个错误,如下所示:

PS C:\Users\hp\Desktop\reactJs-project\NextJs\test-app> npm run build

> test-app@0.1.0 build
> next build

info  - Checking validity of types
info  - Creating an optimized production build .node:events:368
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, open 'C:\Users\hp\Desktop\reactJs-project\NextJs\test-app\.next\trace'
Emitted 'error' event on WriteStream instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {    
  errno: -4048,
  code: 'EPERM',
  syscall: 'open',
  path: 'C:\\Users\\hp\\Desktop\\reactJs-project\\NextJs\\test-app\\.next\\trace'
}
Run Code Online (Sandbox Code Playgroud)

所以我只是想知道有什么办法可以解决这个问题吗?

Ste*_*ers 33

发布 Koronag 的评论作为答案(因为它帮助我解决了这个错误,并且似乎是最可能的原因)...

当开发服务器已在运行时运行构建时,通常会出现此错误。

例如,在我的例子中,我有一个本地构建正在运行npm run dev,并试图提交/推送代码,这调用了一个也运行的 Git Hook npm run dev


小智 0

来自 next-sitemap 仓库 README.md

“使用 next-sitemap 命令和 next-sitemap.js 文件可能会导致文件打开,而不是在 Windows 计算机中构建站点地图。

作为解决方案,现在可以使用自定义配置文件而不是 next-sitemap.js。只需传递 --config .js 即可构建命令。”

Next-Sitemap README.md - 构建站点地图

以上对我有用