How to read a text file in Node.js

Hi Guys! In this tutorial I will explain to you how you can read a text file by using Node.js Framework.

I hope you have installed Node.js. Now, create a new folder and create a file called app.js. You must also create a text file, called text.txt.

Next, in the file text.txt write something.

Open the app.js file and write:

var fs = require('fs');


Now, open the command line from the created folder and enter: node app.js.

Video tutorial:

Leave a Comment