I tried to read line by line in file, but I have a doubt how to print count of line in file using nodejs
.
data.js
console.log("123")
console.log("123")
console.log("123")
console.log("123")
file.js
var lineReader = require('readline').createInterface({
input: require('fs').createReadStream('./data.js')
});
lineReader.on('line', function (line) {
console.log('Line from file:', line);
});
I got this ouput
Line from file: console.log("123") Line from file:
Line from file: console.log("123") Line from file:
Line from file: Line from file: console.log("123") Line from file: Line from file: Line from file: Line from file: console.log("123")
but I want how many lines of code in file using node js