CreateReadStream read comments and reported an error

fscreateReadStream
router.post("/", function(req, res, next) {
    var readStream = fs.createReadStream("./public/javascripts/Json.json");
    var data = "";
    readStream.on("data",(chunk)=>{
        data = data+chunk;
    })
    readStream.on("end",()=>{
        var tmp = JSON.parse(data);
        res.send(tmp);
    })
});
Json.json
/*{
    "head":{
        "resolution":"600x100"
    },
    "data":{
        "info":"wangergou"
    }
}*/
gitBash

< hr >

access to createReadStream documents has autoClose:false; as a treasure, but failed to use it.

how can comments be read and sent to the front end? Or read uncommented code snippets directly, bypassing comments?

< hr >

under the adopted QQ, the positioning problem is that json.parse (), encounters / * comments, which is consistent with the fact that json itself does not allow comments.
all I have to do is break the rules of json, so I will not change the "string" after the byte stream reading to json, to process it using rules

    readStream.on("end",()=>{ 
        console.log(typeof data,data.constructor);              //1
        var tmp = data.replace(/\/\*(\s|.)*?\*\//g,"");
        console.log(tmp);                                       //2  
    })

now the first console.log print string function String () {[native code]}

Mar.15,2021

how can comments be read and sent to the front end? Or read uncommented code snippets directly, bypassing comments?

json is impossible json , not in a lifetime json . The best way, of course, is to get rid of the comments. Or

  1. regularly remove / *. * / .
  2. change the comment to a description field or an extension field.
  3. remove JSON.parse and do not request json resource request js resource.

JSON files cannot be commented

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b317-3463f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b317-3463f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?