// hello.js
fs = require('fs');
fs.writeFile('hello.txt', 'Hello, World!', err => {
if (err)
console.log(err);
console.log('success');
});
The output of $ node hello.js is success, as expected. The hello.txt file is created, but is blank on checking the contents.
I've tried every variation of this code I could think of, using append and write methods, *Sync() versions of the methods, and writing to the file using filestreams. None have worked.
Hi @monodokimes!
Thanks for the bug report.
Does the problem still occur if you remove hello.txt before running the script?
If yes, can you upload and share the output of running strace node hello.js somewhere (you might need to install the strace utility first on your system)?
The problem occurs consistently trying to create and write to any file, whether the file exists before the call or not.
Output of strace node hello.js: https://pastebin.com/F2yUS3zD
@monodokimes Can you also post the output of strace -f node hello.js? Without -f it only traces the main thread.
I have run the code and it created the file successfully whit "Hello, World! " inside, maybe the problem is another thing
@bacriom I'm pretty sure it's a platform problem, I would find it hard to believe fs is this fundamentally broken everywhere.
No follow-up, closing.
Most helpful comment
I have run the code and it created the file successfully whit "Hello, World! " inside, maybe the problem is another thing