I am trying to read data from a json file but I get Error: ENOENT even though from what I can see, the file path has been written correctly.
The code I am running:
const fs = require("fs");
const testing = require("./test.json")
console.log("yes") // works
const testData = fs.readFileSync("./test.json");
console.log(testData); // returns Error: ENOENT
I have tried writing different file paths, testing in another project, deleting and reinstalling package-lock.json, reinstalling node, still getting Error: ENOENT: no such file or directory, open './test.json'
. How can I prevent this error, or, is there a node module that I can install that would let me read and write to a json file?