I've read multiple threads here on Stackoverflow, but can get this to work.
My file (that exists, have double checked) that i try to read is located in
/src/files/2022.json
I have tried both relative path and direct path.
Output for debuging returns the following process.cwd() = "/Users/MYNAME/Dropbox/Mac/Documents/projects/checker-be" __dirname = "/Users/MYNAME/Dropbox/Mac/Documents/projects/checker-be/src/helpers"
I have tried the following code, which outputs the error message below the code:
fs.readFileSync(path.join(__dirname, '../files/2022.json'), {encoding:'utf8', flag:'r'});
ENOENT: no such file or directory, open '/Users/MYNAME/Dropbox/Mac/Documents/projects/checker-be/src/files/2022.json'
fs.readFileSync('./src/files/2022.json', {encoding:'utf8', flag:'r'});
Error: ENOENT: no such file or directory, open './src/files/2022.json'
What am I doing wrong? If Im missing posting something, please let me now.