0

I am trying to build the next Js app production files to deploy it on cPanel, when I execute npm run dev the app is working just fine but as I start to build a production file with the help of this video(https://youtu.be/1ykSXau838c) and executes npm run build it gives me an error in the terminal as given below:

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'
}

so I just want to know is there any way to solve this problem?

  • Try this: https://stackoverflow.com/questions/34600932/npm-eperm-operation-not-permitted-on-windows – Shri Hari L Apr 13 '22 at 04:14
  • 3
    Are you currently running the app in dev? If yes, cancel that process and try to build it again. Most likely the build is not able to access the trace due to being open by the dev process. – Koronag Apr 13 '22 at 04:45

1 Answers1

0

From next-sitemap repo README.md

"Having next-sitemap command & next-sitemap.js file may result in file opening instead of building sitemaps in windows machines.

As a solution to this, it is now possible to use a custom config file instead of next-sitemap.js. Just pass --config .js to build command."

Next-Sitemap README.md - Building Sitemaps

The above worked for me

Isaac
  • 1