I’m using Node.exe in the following file structure
Node/
node.exe
index.js
/view
index.html
When running the following code:
var html;
fs.readFileSync('/view/index.html', function(err, data) {
if(err){
throw err;
}
html = data;
});
I get the following error:
Error: ENOENT, The system cannot find the file specified. '/view/index.html'
Can you see what’s causing the error? I’m quite new to node.js.
Additional information:
I’m running Windows 7 64 bit, up to date version of node.exe.
I’ve found the solution!
When node.exe is run through cmd the default directory for node.exe is user…. that’s where I was going wrong, it wa using a different directory to where the node.exe is located.
Few things:
Rough code will be:
Note that I am using version 4.11 (latest stable version)