I'm not sure if this will be helpful, but I encountered a similar issue with my Express.js project. The project worked perfectly locally, but when I deployed it to Vercel, I faced errors because Vercel adds the '/var/task/' prefix to every relative path.
I modified the code by adding const path = require('path');, which is a built-in Node.js module that provides utilities for working with file and directory paths. I then updated the relative paths accordingly. For instance, I changed const collegeData = require("./modules/collegeData"); to const collegeData = require(path.join(__dirname, "modules", "collegeData"));. This method ensures that the paths are constructed correctly regardless of the environment. I also updated './data/students.json' to path.resolve(__dirname, '../data/courses.json');.
Can you implement something similar?