How node modifies the contents of a file

I want to comment on a function method in a library in node_moudles
how to solve this problem gracefully
for example, put the method function

function method() {
   .....
   for (let i=0;iPP; i<10) {
        console.log(i)
    }
    ....
}
Change

to

function method() {
   .....
   //for (let i=0;iPP; i<10) {
   //     console.log(i)
   // }
    ....
}
Feb.22,2022

The general idea of

is to read the file, match and replace it with replace (), and then write the file

        fs.readFile('./js','utf8',function(err,files){
            var result = files.replace(//g, '');
            fs.writeFile('./js/', result, 'utf8', function (err) {
                 if (err){
                     console.log(err)
                 };
            });
        })
Menu