vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.25k stars 26.77k forks source link

Emitted 'error' event on WriteStream instance #30738

Open maximegheraille opened 2 years ago

maximegheraille commented 2 years ago

What version of Next.js are you using?

12.0.2

What version of Node.js are you using?

v14.11.0

What browser are you using?

chrome

What operating system are you using?

windows

How are you deploying your application?

next run build

Describe the Bug

Hi,

When making a build for production, I keep getting this error. I never had the issue before upgrading to version 12.0.0. I tried deleting the file, but it only works when the dev server is not running, while it runs I cannot open or delete it and that make every production build fail.

info  - Creating an optimized production build .events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, open 'D:\[...]\.next\trace'
Emitted 'error' event on WriteStream instance at:
    at D:\[...]\node_modules\next\dist\compiled\@vercel\nft\index.js:1:287421
    at D:\[...]\node_modules\next\dist\compiled\@vercel\nft\index.js:1:287860
    at FSReqCallback.oncomplete (fs.js:164:23) {
  errno: -4048,
  code: 'EPERM',
  syscall: 'open',
  path: 'D:\\[...]\\.next\\trace'
}

Expected Behavior

I expect it to work when building

To Reproduce

clone the with-typescript example, run npm run dev and once done npm run build

kmsomebody commented 2 years ago

Same error here, but different lines. Can't build 12.0.2.

info  - Creating an optimized production build ...node:events:371
      throw er; // Unhandled 'error' event
      ^

Error: EPERM: operation not permitted, open 'D:\[...]\.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: 'D:\\[...]\\.next\\trace'
}
maximegheraille commented 2 years ago

I might have found the problem. I used the with-typescript example. When running npm run buid it works fine but when I have dev running via npm run dev and I build it, it gives that error. Before version 12.0.0 is always had the dev running while doing a production build. (it was required for production build if I am not wrong)

timneutkens commented 2 years ago

@maximegheraille that is definitely helpful, I can see why that would indeed fail, note that it was never intended that next build while next dev is running would work, it's accidental that it worked before. There's other issues including shipping development bundles to production holding unminified code and such that would already exist in that case.

Not sure if we can detect next build is running while in next dev 🤔

AndrewUsher commented 2 years ago

I'm able to reproduce the issue without running both simultaneously. I'm seeing the same error as well when running next dev on a Windows machine. We run a reverse proxy at the same time as well and use a custom Express server (not sure if that helps narrow down the issue, just wanted to call it out 😄 )

avdhootk commented 2 years ago

you just need to stop the npm run dev and then run npm run build, that works for me

Relison commented 2 years ago

Para que usa o yarn é mesma coisa, só precisa parar yarn dev , depois executar yarn build

maryamtalebnejad commented 2 years ago

I might have found the problem. I used the with-typescript example. When running npm run buid it works fine but when I have dev running via npm run dev and I build it, it gives that error. Before version 12.0.0 is always had the dev running while doing a production build (it was required for production build if I am not wrong).

solved my problem thanks

Augusto1996-sys commented 2 years ago

Para que usa o yarn é mesma coisa, só precisa parar yarn dev , depois executar yarn build

Eu tenho que correr o servidor porque preciso da conexao com a API e por isso estou tendo o mesmo problema como faco para solucionar???

nttminh commented 1 year ago

I might have found the problem. I used the with-typescript example. When running npm run buid it works fine but when I have dev running via npm run dev and I build it, it gives that error. Before version 12.0.0 is always had the dev running while doing a production build (it was required for production build if I am not wrong).

Solved! Thank you

zbq30 commented 1 year ago

你只需要停止 npm 运行开发,然后运行 npm 运行构建,这对我有用

完美解决