Answer the question
In order to leave comments, you need to log in
Why does readFile throw an error that the file was not found?
I am trying to read json file. If I do it through require, then it reads everything:
but if I do it through readFile or readFileSync, then it gives an error ENOENT: no such file or directory.
what could be the problem?
const data = require('./json/name.json')
const data = fs.readFileSync('./json/name.json')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question