Windows NodeJS: Always gets either "Error: ENOENT: No such file or directory open" or "Error: EACCES: Allowed, Denied",
Here is my code:
var fs = require('fs');
var util = require('util');
var logFile = fs.createWriteStream('C:/text.txt', { flags: 'a' });
// Or 'w' to truncate the file every time the process starts.
var logStdout = process.stdout;
console.log = function () {
logFile.write(util.format.apply(null, arguments) + '\n');
logStdout.write(util.format.apply(null, arguments) + '\n');
}
console.error = console.log;
Regardless of what I type instead of "C: /text.txt", I either get
Error: ENOENT: No such file or directory, open
or
Error: EACCES: permission denied, open
I've tried everything like "run as administrator" and "raise", but when it's not the second error message, it's the first; and when he's not the first, he's the second.
I am embarrassed.
+3
source to share