read txt file in node js

const fs = require('fs');

// Step 1: Specify the file path
const filePath = 'path/to/your/file.txt';

// Step 2: Use the 'fs' module to read the file
fs.readFile(filePath, 'utf8', (err, data) => {
  // Step 3: Handle any errors that occurred during the file read
  if (err) {
    console.error('Error reading the file:', err);
    return;
  }

  // Step 4: Process the file data (in this example, simply log it)
  console.log('File content:', data);
});