Answer the question
In order to leave comments, you need to log in
Node.js - How to count lines in a file?
On hand there are files with a text format. How to count the number of lines in a file using Node.js?
ps I also forgot to say that the number should be one, not several numbers.
Answer the question
In order to leave comments, you need to log in
const fs = require('fs');
const data = fs.readFileSync('text.txt').toString();
console.log(data.split('\n').length);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question