Answers for "how to write in a file using node js"

16

writefile in node js

// writefile.js

const fs = require('fs');

let lyrics = 'But still I\'m having memories of high speeds when the cops crashed\n' + 
             'As I laugh, pushin the gas while my Glocks blast\n' + 
             'We was young and we was dumb but we had heart';

// write to a new file named 2pac.txt
fs.writeFile('2pac.txt', lyrics, (err) => {
    // throws an error, you could also catch it here
    if (err) throw err;

    // success case, the file was saved
    console.log('Lyric saved!');
});
Posted by: Guest on March-15-2020
0

write files in Node.js

var fs = require('fs');  
var txt = '\n' + tkn_psid_id + ':' + assetUrl;
var folderName = '/duplicates/bugging/videobug/' + tkn_psid_id + '.txt';
fs.appendFile(folderName, txt, function (err) {
       if (err) {
                console.log('Append Error');
           } else {
                   console.log('DuplicateFolder' + folder);
            }
      });
Posted by: Guest on July-12-2021

Code answers related to "how to write in a file using node js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language