While using fs.readFileSync i encountered a problem loading a config file.
Result of __dirname
console.log(__dirname); >>>>>> C:\Users\MYUSER\Desktop\Development\ehrekonto\api\server\api\routes
The config file i'm trying to load is located one directory above:
C:\Users\MYUSER\Desktop\Development\ehrekonto\api\server\api\configs\protected.json
I'm using fs.readFileSync inside the route users that is required and loaded by app.js in the server root.
fs.readFileSync("../configs/protected.json");
Problem solved with help by Jakob on the Javascripters discord.
fs.readFileSync(path.resolve(__dirname, '../configs/protected.json'));