Next.js Discord

Discord Forum

node 16.x support puppeteer?

Unanswered
Alι_ Aryαɴ posted this in #help-forum
Open in Discord
Hey, there!

I was using node 14.x back then, but today I need to make some changes in my project but when I pushed it to deployment it Failed, I get to know today node 14.x have deprecated, so that I updated to 16.x

When, I use my express API it didn't work!

Here, package.json:
{
   "private": true,
   "dependencies": {
      "chrome-aws-lambda": "7.0.0",
      "express": "^4.17.1",
      "fs-extra": "^11.0.0",
      "puppeteer-core": "13.1.2"
   },
   "devDependencies": {
      "typescript": "4.1.5"
   },
   "engines": {
      "node": "16.x"
   }
}


Here, code:
import { launch, Page } from 'puppeteer-core';
import chrome from 'chrome-aws-lambda';
let page: Page | null;

async function getPage() {
    if (page) return page;
    const browser = await launch({ 
        args: chrome.args,
        executablePath: await chrome.executablePath,
        headless: chrome.headless
    });
    page = await browser.newPage();
    return page;
}


Here, are the logs:
TypeError: Cannot read properties of undefined (reading '_launcher')
    at launch (/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/node/Puppeteer.js:125:21)
    at /vercel/path0/api/lib/Scrap.ts:7:27
    at step (/var/task/api/lib/Scrap.js:33:23)
    at Object.next (/var/task/api/lib/Scrap.js:14:53)
    at fulfilled (/var/task/api/lib/Scrap.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)


So, The Question is which version is supported on 16.x?? 🤔

14 Replies

European sprat
This is a next.js support discord
I don't sure about older versions, but node.js 18 should work for the latest versions of all your depenencies
@fuma I don't sure about older versions, but node.js 18 should work for the latest versions of all your depenencies
I updated modules to latest and node to 18.x

Still
Error: Failed to launch the browser process!
/tmp/chromium: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory


TROUBLESHOOTING: https://pptr.dev/troubleshooting

    at Interface.onClose (/var/task/node_modules/@puppeteer/browsers/lib/cjs/launch.js:277:24)
    at Interface.emit (node:events:525:35)
    at Interface.close (node:internal/readline/interface:533:10)
tbh I'm not familiar with puppeteer. I found this solution on StackOverflow which I think is useful: https://stackoverflow.com/a/67117619/16322371
but it's no longer support now on vercel
Philippine Crocodile
I use Puppeteer in Next.js components and the build fails me often, but I trigger building second time and passes me correctly (I'm using Vercel and click "redeploy").
    at ChromeLauncher.resolveExecutablePath (/vercel/path0/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:300:27)
    at ChromeLauncher.executablePath (/vercel/path0/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:180:25)
    at ChromeLauncher.computeLaunchArguments (/vercel/path0/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:97:37)
    at async ChromeLauncher.launch (/vercel/path0/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:79:28)
    at async Diagram (/vercel/path0/.next/server/chunks/296.js:101:21)
Error: Could not find Chrome (ver. 115.0.5790.102). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /vercel/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
Puppeteer was working on 14.x
But they deprecated 14.x
Now we need to know which version of puppeteer will work on node 16.x or 18.x