How to write files in node.js?
Answer / 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 |
What are node packages and how to install/uninstall them?
Explain what is a javascript engine?
What is a Callback function in Node.js?
Using the event loop what are the tasks that should be done asynchronously?
How will you close a file using node?
How do callbacks work?
Is node.js free to use?
What is rest api in node js?
How will you read a directory?
What is npm? What is the main functionality of npm?
What is orm in node.js?
Why to use node.js?