I use netlify functions for API calls to MongoDB, S3 and more. Locally everything is working fine. When I try this in production it does not work and I can’t seem to know why it doesn’t…
In my functions folder I have a file called test.js.
const test = require("./test/testFunction")
exports.handler = async function (event, context) {
return test(event,context);
}
Inside this test.js I require another file named testFunction which returns a statuscode and body.
On common thing that may lead to runtime errors on function is a mismatch between the node version of the build and the function runtime. Can you make sure both are the same and set them using environment variables:
Particularly these:
AWS_LAMBDA_JS_RUNTIME and NODE_VERSION
Try setting them as the same node version you’re running locally.
It looks like you’ve opened a separate thread that looks quite similar.
In that thread you’ve mentioned the issue might have something to do with including files in subdirectories. As Hrishikesh mentioned, we’ll need a minimal repro to help debug further. Let us know if that’s possible!