Skip to content

Instantly share code, notes, and snippets.

@umidjons
Created January 5, 2014 08:02
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save umidjons/8265657 to your computer and use it in GitHub Desktop.
Save umidjons/8265657 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!');
});
@jnoe2233
Copy link

hey

@Avinashachu007
Copy link

Make it Sync. because it is first appending and then writting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment