How do you write a file using node.js?



How do you write a file using node.js?..

Answer / Sukhdarshan Singh

You can write to a file in Node.js using the built-in 'fs' module. Here is an example:n```javascriptnconst fs = require('fs');nfs.writeFile('myfile.txt', 'Hello World!', (err) => {n if (err) throw err;n});n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Node.js Interview Questions

Does nodejs need java?

1 Answers  


What is let in node js?

1 Answers  


How do you resolve unhandled exceptions in a Node.js program?

1 Answers  


Who is the author of node js?

1 Answers  


What are the important events of net.Socket in Node.js?

1 Answers  


Why is js single threaded?

1 Answers  


Explain 'buffer class' in node.js?

1 Answers  


Explain the usage of a buffer class in node.js?

1 Answers  


What is the purpose of process object?

1 Answers  


Why is node asynchronous?

1 Answers  


List some events that fired by streams in node js?

1 Answers  


Write the steps for setting up an express js application.

1 Answers  


Categories