How can I replace the img src value using node-html-parser in server side?

I have html code, and I want to change the src value on the <img tag in server side. I was using node-html-parser library.
Here’s my code :

const root = HTMLParser.parse(templateContent);

let base64Image = root.querySelector('img').rawAttributes.src;
console.log('here');
root.getElementsByTagName('img')[0].rawAttributes.src.set_content('src:image');
console.log(root.toString())
process.exit()
...

But when I run the code above, the result is just print here, and the next line is not executed, even the process.exit().

Is there any mistake that I made ? I just want to change the src value inside the <img tag.
Please ask me for more information if it’s still not enough to solved it, Thankss