How will you read a file using node?



How will you read a file using node?..

Answer / Dispreet Kaur

You can read a file in Node.js by using the built-in `fs` (file system) module. Here is an example:n```javascriptnconst fs = require('fs');nfs.readFile('filename.txt', 'utf8', (err, data) => {n if (err) throw err;n console.log(data);n});n``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Node.js Interview Questions

How to check the already installed dependencies using npm?

1 Answers  


What are global variables in node.js?

1 Answers  


Difference between dependencies and dev dependencies?

1 Answers  


Is node.js a single threaded application?

1 Answers  


List down the two arguments that async.queue takes as input?

1 Answers  


What you mean by JSON?

1 Answers  


How to create a simple node js application?

1 Answers  


How you can update NPM to new version in Node.js?

1 Answers  


Explain repl in the context of node.js.

1 Answers  


What is File System module in Node.js?

1 Answers  


What is template engine?

1 Answers  


What is the difference between nodejs and expressjs?

1 Answers  


Categories