adspace


How to write files in node.js?

Answer Posted / Anurag Singh Chauhan

To write a file in Node.js, use the 'writeFile' function from the 'fs' module. Here's an example:n```javascriptnconst fs = require('fs');nnconst data = 'Hello World';nnfs.writeFile('output.txt', data, (err) => {n if (err) throw err;n console.log('The file has been saved!');n});n```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How we can read a file in node js?

568


Is node js losing popularity?

588