nodejs not reading file

Support
  • const fs = require('fs');
    
    const filePath = 'f:\\Users\\Desktop\\mp4\\d.txt'; // Replace with the actual file path
    
    fs.readFile(filePath, 'utf8', (err, data) => {
      if (err) {
        console.error(`Error reading file: ${err}`);
      } else {
        console.log(`File contents:\n${data}`);
        console.log("Hello, World!");
      }
    });
    

    I am trying to run this code but nothing is happening inside the nodejs in bas but when I run it locally on my computer its working perfectly find can bas nodejs not read file?

  • @Bunnz said in nodejs not reading file:

    const fs = require('fs');
    
    const filePath = 'f:\\Users\\Desktop\\mp4\\d.txt'; // Replace with the actual file path
    
    fs.readFile(filePath, 'utf8', (err, data) => {
      if (err) {
        console.error(`Error reading file: ${err}`);
      } else {
        console.log(`File contents:\n${data}`);
        console.log("Hello, World!");
      }
    });
    

    I am trying to run this code but nothing is happening inside the nodejs in bas but when I run it locally on my computer its working perfectly find can bas nodejs not read file?

    https://community.bablosoft.com/topic/4450/websocket-на-node-js/6

  • @Bunnz

    const fs = require('fs').promises;
    
    const filePath = 'f:\\Users\\Desktop\\mp4\\d.txt'; // Replace with the actual file path
    
    [[DATA]] = await fs.readFile(filePath, 'utf8')
    

  • 0 Votes
    5 Posts
    683 Views
  • nodejs functions

    Support
    0 Votes
    3 Posts
    541 Views
  • 0 Votes
    2 Posts
    664 Views
  • Parsing all lines from text file

    Support
    0 Votes
    2 Posts
    878 Views
  • 0 Votes
    2 Posts
    1177 Views