2
I’m trying to fix a mistake in the following code:
const fs = require('fs')
fs.readFile('dados/arqui2vo.json', (err, data) => {
if (err) throw new Error(`Can't find the file`)
When I run the code, this message appears on the console:
c:\Users\<User>\Documents\Node\readFile.js:5
if (err) throw new Error(`Can't find the file`)
^
Error: Can't find the file
at ReadFileContext.fs.readFile [as callback] (c:\Users\<User>\Documents\Node\readFile.js:5:20)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:237:13)
How can I show the error message I created? This is the message I’d like to appear on my console:
Error: Can't find the file
Welcome to Stack Overflow in English. Please click on edit and translate the question.
– Luiz Augusto
So far you have not edited your question. Our colleague warned you and there is no editing in it. -1
– Maury Developer