You can resolve the path relative the location of the source file – rather than the current directory – using path.resolve:
const path = require("path");
const file = fs.readFileSync(path.resolve(__dirname, "../file.xml"));
You can resolve the path relative the location of the source file – rather than the current directory – using path.resolve:
const path = require("path");
const file = fs.readFileSync(path.resolve(__dirname, "../file.xml"));