Motyar

@motyar

Freelance Web Developer

Static Web Hosting, made easy

Jan 2, 2014

Writing files in NodeJS

Want to process and create files in NodeJs?
filesystem API is what you are looking for.

To use this module use require('fs'). All the methods can be called asynchronous or synchronous forms.

 Here is a very basic example


var fs = require('fs');
fs.writeFile("/tmp/test", "Hey there!", function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("The file was saved!");
    }
}); 

more about it on this StackOverflow thread.

Check full NodeJs course here. Learning NodeJs

Labels: ,




By :