【问题标题】:Next JS : Error: EPERM: operation not permitted, openNext JS:错误:EPERM:不允许操作,打开
【发布时间】:2022-07-18 23:47:44
【问题描述】:

当我执行时,我正在尝试构建下一个 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'
}

所以我只想知道有没有办法解决这个问题?

【问题讨论】:

  • 您当前是否在 dev 中运行该应用程序?如果是,请取消该过程并尝试再次构建它。由于被开发进程打开,构建很可能无法访问跟踪。

标签: reactjs deployment next.js cpanel


【解决方案1】:

来自下一个站点地图 repo README.md

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

作为解决方案,现在可以使用自定义配置文件代替 next-sitemap.js。只需通过 --config .js 来构建命令。”

Next-Sitemap README.md - Building Sitemaps

以上对我有用

【讨论】:

    【解决方案2】:

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

    在开发服务器已在运行的情况下运行构建时通常会出现此错误。 (例如,在我的情况下,我有一个通过 npm run dev 运行的本地构建,并试图提交/推送代码,该代码运行了一个也运行 npm run dev 的 Git Hook。)

    【讨论】:

      猜你喜欢
      • 2018-06-07
      • 1970-01-01
      • 2021-08-18
      • 2022-11-08
      • 2016-01-29
      • 2022-08-16
      • 1970-01-01
      • 2021-01-14
      • 2021-11-18
      相关资源
      最近更新 更多