Puppeteer nodejs Error: input.on is not a function\n at new Interface

Viewed 342

M generating a pdf from html using the npm module puppeteer.
When the running the following code m getting an error.
It is working properly on windows , but when the same is executed on linux red hat server , it is giving an error

    let poptions = {
        path: pdfPath, scale: 0.8, printBackground: true, format: "letter"
        ,"margin": {
            "bottom": 70, 
            "left": 25,
            "right": 35,
            "top": 70,
        },
        landscape:true
    }
    console.log(htmlPath);
    const browser = await puppeteer.launch({ args: [
        '--no-sandbox'
      ],"dumpio": true})    
  const page = await browser.newPage();
  page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
      await page.goto(htmlPath);
    // await page.emulateMedia('print');
    poption=Object.assign(poptions,pageoptions)
    if(pageStyle)await page.addStyleTag(pageStyle);    
    const pdf = await page.pdf(poptions);
    await browser.close();
Error: input.on is not a function
 at new Interface (readline.js:207:11)
 at Object.createInterface (readline.js:75:10)
 at Promise (/microservice/node_modules/puppeteer/lib/Launcher.js:329:25)
 at new Promise ()
 at waitForWSEndpoint (/microservice/node_modules/puppeteer/lib/Launcher.js:326:10)
 at Launcher.launch (/microservice/node_modules/puppeteer/lib/Launcher.js:170:41)
1 Answers

Used the following parameters while launching the chrome.--disable-setuid-sandbox resolved the issue

const browser = await puppeteer.launch({ args: [
    '--no-sandbox',
    '--disable-setuid-sandbox',
    '--headless',
    '--disable-dev-shm-usage',
    '--disable-gpu',
    '--disable-features=NetworkService',
    '--window-size=1920x1080',
    '--disable-features=VizDisplayCompositor',
    '--log-file=/home/ec2-user/credence/microservices/reporting-server/log/server.log',
    '--log-level=0'
    ],"dumpio": true})
Related