Build fails after loading external data and saving it to JSON

Hi,
I’m trying to help local school build their site and they have some data stored in Google Blogger. So I want to scrape that data and store it locally to generate those pages. But when I want to access that JSON file, it fails because it doesn’t find that file. Is there maybe some different path?

To store the data i use fs.writeFileSync(./data/all.json, JSON.stringify(all));. And to access it then in getStaticProps I use const filePath = path.join(process.cwd(), data/all.json);. Locally it works, but on Netlify fails due to Error: ENOENT: no such file or directory, open './data/all.json'. Any help would be really appreciated! Thanks!

I think you should use this:

to write the file as well. For example:

fs.writeFileSync(path.join(process.cwd(), ./data/all.json), JSON.strigify(all))

Yes, thanks @hrishikesh , that was it. I had to also put a check for directory and create one since it’s not copied from the repo. Thanks for your quick response!