Write file . txt Node.js

Asked

Viewed 10,235 times

4

I need to generate a txt file with some information and save it to C: How can I do this using Node.js?

1 answer

4


Using the API filesystem nodejs.

The API has a lot of details and gives you endless possibility, take a read on documentation for more details.

Remember that you must have permission to write to the folder.

A very simple example.

var fs = require('fs');

fs.writeFile("C:\\Pasta\\meuarquivo.txt", "Hello, txt!", function(erro) {

    if(erro) {
        throw erro;
    }

    console.log("Arquivo salvo");
}); 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.