Docker-based Puppeteer Fails to Launch the Expected Chrome on Node 16-Buster

Using Node 16-buster, my Docker container fails to launch Puppeteer’s specified Chrome version. Dependency setup and explicit versioning result in unexpected AWS behavior.

FROM node:16-buster

RUN apt-get update && apt-get install -y \
    ca-certificates chromium fonts-liberation libnss3 libatk-bridge2.0-0 \
    libx11-6 libxcb1 xdg-utils && apt-get clean

RUN mkdir -p /root/.cache/browser_cache && chmod -R 777 /root/.cache/browser_cache

WORKDIR /app

COPY app*.json /app/
RUN npm install

RUN npx browser-manager install [email protected]

ENV BROWSER_EXEC=/root/.cache/browser_cache/chrome/linux-131.0.6778.69/chrome64/chrome

COPY . /app
RUN npm run compile
EXPOSE 5001
CMD ["node", "build/server.js"]
import extraBrowser from 'puppeteer-extra';
import HiddenMode from 'puppeteer-extra-plugin-stealth';

extraBrowser.use(HiddenMode());

async function fetchItems(searchParams, useBudget, maxLimit = -1, minLimit = -1) {
    console.log('Chrome path:', extraBrowser.executablePath());
    const browserInst = await extraBrowser.launch({ headless: false, args: ['--no-sandbox', '--disable-setuid-sandbox'] });
    const tab = await browserInst.newPage();
    await tab.setViewport({ width: 1280, height: 720 });

    try {
        await tab.goto(`https://example.com/search?q=${encodeURIComponent(searchParams[0].term)}`, { waitUntil: 'domcontentloaded' });
        return { ok: true };
    } catch (err) {
        return { ok: false, msg: err.message };
    } finally {
        await browserInst.close();
    }
}

export { fetchItems };

hey, i had a simlar issue. i ended up symlinking the desired chrome binary and adjusting the env var. check if your path and version match what puppeteer expects. hope it helps