I am trying to read a file from local system using node js 'fs' module. But for some reason, the 'fs' module is not working when I pass absolute path.
let filePath = "/home/mysystem/dev/myproject/sayHello.txt";
Uncaught Error: ENOENT: no such file or directory, open 'file:///home/mysystem/dev/myproject/sayHello.txt'
In NodeJS you don't have to use the
file protocol for reading files.
You can get rid of the
"file://" part and try read the
let filePath = "/home/mysystem/dev/myproject/sayHello.txt"; let newFile = fs.readFileSync(filePath);