Skip to content

Instantly share code, notes, and snippets.

@ismnoiet
Forked from umidjons/write-append-file.js
Created March 14, 2016 08:58
Show Gist options
  • Save ismnoiet/1d0e6b5676727db9462f to your computer and use it in GitHub Desktop.
Save ismnoiet/1d0e6b5676727db9462f to your computer and use it in GitHub Desktop.
NodeJS: Write/Append into a file
var f='write.txt',
fs=require('fs');
fs.writeFile(f,'Some text to write.',function(err){
if(err)
console.error(err);
console.log('Written!');
});
fs.appendFile(f,'Some more text to append.',function(err){
if(err)
console.error(err);
console.log('Appended!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment