file pathname is not found on the production mode using fs.writeFile

51 Views Asked by At

i have a api route in my nextjs project and i'm using fs.writeFile method such as await fs.writeFile( process.cwd() + '/app/data/list.json', data ) It is working properly on development and local production mode, but not working on the vercel build. It throws an error code: "ENOENT" errno: -2 meaning that file not found What should i do to make it work properly on the vercel build, and why is that happening?

I tried __dirname instead of process.cwd() but not worked

0

There are 0 best solutions below