I am currently working on developing a project using the NextJS environment. In this project, I have some JSON files stored in a folder within my root directory, and I am reading the content of these files in my code. Everything works fine on my local machine, but when the project is deployed on the Vercel server, it is unable to read the file because the file does not exist on the server.
Here is the file structure of my project on my local machine:
|--.next
|--components
|--jsonfiles
|--node_modules
|--pages
|--public
|--package.json
(and more)...
However, after deployment, when I try to read the content of the root directory using fs.readdirSync("./")
, it only shows the following files and directories:
|--.next
|--___next_launcher.js
|--___vc_bridge.js
|--node_modules
|--package.json
And here is the code I am using to read the file:
const fs = require('fs');
const rawcontent = fs.readSync('./jsonfiles/list.json');
const list = JSON.parse(rawcontent);
...
Do you have any solutions to this issue?