The acquisition timestamp of the homemade module in node cannot be updated.

< H2 > question < / H2 >

was timestamped in the module of require, and the second time also got the same timestamp as the first time.

< H2 > Code < / H2 >

the previous code is normal, first only give the problem, the boss needs me to post all of it

a.js uses express router

let module = require("./b.js");
router.post("/api",(req,res)=>{
    b.main(()>{
        req.status(200).json({})
    })
})

b.js

function main(){
    if(true){
        let cmodule = require("./c.js");
        cmodule.main()
    }
}
exports.main = main

c.js

var fs = require("fs"),
    timestamp = new Date().getTime(),
    dhh = fs.createWriteStream("./aa"+timestamp+".txt");
function main(){
    console.log(timestamp)
    if(){
        dhh.end("Done"); // , 
        return;
    }
    stream = fs.createReadStream("./aa.txt");
    stream.pipe(dhh, {end: false});
    stream.on("end", function() {
        main();        
    });
}
exports.main = main

index.html

ajax.post "/api"

console

 console.log(timestamp) 1526885307155

 console.log(timestamp) 1526885307155
,~
Mar.12,2021

your c module has been executed as soon as it is loaded, and the results after execution are all obtained

Menu