readLines
Convenience method to create a readline interface and stream over the file. See filehandle.createReadStream() for the options.
import { open } from 'node:fs/promises';
const file = await open('./some/file/to/read');
for await (const line of file.readLines()) {
console.log(line);
}Content copied to clipboard
Since
v18.11.0