whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

"_projectRoot is undefined. Unable to create a BrowserFetcher" while running an app in docker

Open StefanoVe opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

the whatsapp client in my app doesn't initialize correctly while running in docker (throwing the following error) but runs perfectly fine on my Macbook

2022-04-20T10:27:22.917053336Z Error: _projectRoot is undefined. Unable to create a BrowserFetcher.
2022-04-20T10:27:22.917057531Z at resolveExecutablePath (/usr/src/app/main.js:202314:15)
2022-04-20T10:27:22.917061555Z at ChromeLauncher.launch (/usr/src/app/main.js:201797:53)
2022-04-20T10:27:22.917068383Z at async Client.initialize (/usr/src/app/main.js:539830:23)

Dockerfile

FROM node:13.11.0

RUN mkdir -p /puppeteer
WORKDIR /puppeteer

COPY ./ /puppeteer
RUN  apt-get update \
     && apt-get install -y wget gnupg ca-certificates \
     && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
     && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
     && apt-get update \
     && apt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils \
     # We install Chrome to get all the OS level dependencies, but Chrome itself
     # is not actually used as it's packaged in the node puppeteer library.
     # Alternatively, we could could include the entire dep list ourselves
     # (https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix)
     # but that seems too easy to get out of date.
     && apt-get install -y google-chrome-stable \
     && rm -rf /var/lib/apt/lists/* \
     && wget --quiet https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -O /usr/sbin/wait-for-it.sh \
     && chmod +x /usr/sbin/wait-for-it.sh

CMD ["node", "main.js"] 

Expected behavior

the app should run fine without throwing any sorts of error

Steps to Reproduce the Bug or Issue

  1. initialize a whatsapp-web.js client
  2. deploy the app on docker
  3. run the app

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Docker whatsapp-web.js version: 1.16.5 Whatsapp Web Version: 2.2212.8 Node.js Version: 13.3

Additional context

No response

StefanoVe avatar Apr 20 '22 16:04 StefanoVe

what ar your pupperteer args?

KeruMx avatar Apr 20 '22 20:04 KeruMx

i haven't set any args

StefanoVe avatar Apr 21 '22 07:04 StefanoVe

Hi @StefanoVe, can recommend you usage of chrome-aws-lambda package, it works in the same way as a puppeteer, but with binary, it solved my issue in lambda function, I guess it should be also case for docker

ghost avatar May 15 '22 10:05 ghost

This might be related to https://github.com/puppeteer/puppeteer/issues/8919

christian-bromann avatar Sep 08 '22 07:09 christian-bromann