I have a script that writes a file to the file system, here is the code:
var filepath = path.join(process.cwd(), '/config/config.js');
var file_contents = 'config stuff';
fs.writeFile(filepath, file_contents, function(err) {
if(err) {
r.errors.push('Could not write config file');
callback(r);
} else {
callback(r)
}
});
It works fine on my MacBook Pro. I installed NodeJS on an Amazon EC2 server and for some reason it wipes the files contents and doesn’t write anything to it.
Any Suggestions ?
Thanks!
Turns out I have Node watching the file for updates. With Mac you can watch a file for updates and still write to it, seems on Amazons EC2 linux AMI, if you are watching a file, you cannot watch and write at the same time.