Not works fs.readFile in node js

后端 未结 5 788

I have:

 fs.readFile(\'../services/Prescipcion.xml\', \"utf8\", function (err, data) {
    console.log(\"err->\", err);
    console.log(\"data\", data);
 });
         


        
5条回答
  •  眼角桃花
    2021-02-19 11:17

    It worked for me

      var fs = require("fs");
    
        const readFIle = path => {
          fs.readFile(__dirname + path, "utf8", (err, data) => {
            if (err) {
              console.log(err.stack);
              return;
            }
            console.log(data.toString());
          });
          console.log("Program Ended");
        };
    

    usage:

    readFIle("/input.txt");

提交回复
热议问题