How to properly import and read JSON file inside gatsby function (works locally)

Hello everyone, really need your help!

I have a gatsby function that tries to read a JSON file ung fs.readFileAsync. My code works locally and even when yarn build / yarn serve is ran. But for some reason in netlify when I call my serverless function. It says “no such file or directory”

My folder structure looks like this…


I’ve tried multiple ways to call it but can’t seem to get it work once deployed in netlify. I’ve also tried adding this code in netlify.toml but still can’t seem to read it

included_files = [“content/**”]

Additionally, i’m trying to install the gatsby-plugin-netlify. But it shows and error in Netlify’s deploy logs:

 2. build.command from netlify.toml                            
2:52:34 PM: ────────────────────────────────────────────────────────────────
2:52:34 PM: ​
2:52:34 PM: $ yarn build
2:52:34 PM: yarn run v1.22.10
2:52:34 PM: $ gatsby build
2:52:38 PM: success compile gatsby files - 1.311s
2:52:38 PM: error There was a problem loading plugin "gatsby-plugin-netlify". Perhaps you need to install its package?
2:52:38 PM: Use --verbose to see actual error.
2:52:38 PM: not finished load gatsby config - 0.021s
2:52:38 PM: error Command failed with exit code 1. (
2:52:38 PM: info Visit for documentation about this command.

hey there, for the second error, could you paste the code from your package.json please?