Can fs in node koa2 create js files?

there is no problem in creating a file in txt format, but when you create a file in js format, you will see that [object Object]
is written like this. IndustryReader is a [{}] Array (object) format

from other files.
    const industryReader = require("../reader.js")
    industryReader[0].reader = parseInt(industryReader[0].reader)+1
    fs.writeFile("reader.js",industryReader,function(err){
        if (!err){
            console.log("wrote data to file.txt")
        }else{
            throw err;
        }
    });
Mar.11,2021

industryReader toString () is called by default, which is changed to

.
fs.writeFile('reader.js',JSON.stringify(industryReader),function(err){
//...
}

to sum up, all the files introduced by fs are in string format, so the files introduced and written are all in string format. Take json as an example, after introduction, you need to call JSON.parse () to convert the string to json format. Before writing, you need to call JSON.stringify () to write the json into a string.

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-1e54844-4d655.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-1e54844-4d655.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?