Closed MadMaxMcKinney closed 2 years ago
I just face this error and found a work around. JSONFileSync read file in runtime, netlify funtions won't include them in build. So I import them into my script import jpJson from "../data/jp.json"
then write a custom adapter to return jpJson
@thainq3127 Could you elaborate some more? I'm not entirely sure what the root of the problem is. Netlify won't include the Lowdb adapters? Is there a way to get Netlify to better include elements in the build? Running "npm run build && npm run start" also seems to work locally so you are right that something is happening on the Netlify side of things.
Netlify won't include json files, I was too dumb to not google this first https://www.netlify.com/blog/2021/08/12/how-to-include-files-in-netlify-serverless-functions/
Since this issue is not related to lowdb's code, can it be closed?
I've got a really simple DB setup that works when running locally but doesn't work once it's hosted on Netlify. Is there something special that needs to be done for this to work? I don't know if this is an issue on Next.js or a limitation of lowdb.
Here is my db file (root/db/db.js)
And my only API route (root/pages/api/cluster.js
I don't get any other error info besides a 500 error on the server-side. I get the error even if all I do is import the
clusterDB
object, so something is happening there.