I am having C/C++ based application. I want to run nodejs script from my C code. The nodejs script looks as below.
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://google.com');
await page.screenshot({path: 'some.png'});
await browser.close();
})();
This script is generated in C code and available in memory. I can dump it to a file and using system() api, I can run the script. I want to avoid that. Is it possible to run the script, present in memory directly using nodejs without dumping it to file.
While executing, if any exception occurs I need to report it back to my C/C++ application through a callback. Is this possible?
EDIT
I know there is a similar question / answer at Calling JavaScript from C++ with node.js , but here still .js file will be in disk and it is executed. Here my question is, how to run nodjs from C/C++ application where the script is available in memory.