whatsapp-web.js: Error: Failed to launch the browser process!

error description

Getting this error when deploying to server, locally is running fine

(node:46580) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process! /var/www/whatsapp-automation/node_modules/whatsapp-web.js/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/var/www/whatsapp-automation/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
at Interface.<anonymous> (/var/www/whatsapp-automation/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:187:68)
at Interface.emit (events.js:412:35)
at Interface.close (readline.js:451:8)
at Socket.onend (readline.js:224:10)
at Socket.emit (events.js:412:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

(Use node --trace-warnings ... to show where the warning was created) (node:46580) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:46580) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Library

  • NodeJS version (14.17.0):
  • whatsapp-web.js version:

Other

  • Operating system (the one running node) [Linux ]:

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24 (4 by maintainers)

Most upvoted comments

Clean the modules and reinstall. It works.

Closing as unrelated to whatsapp-web.js. This is likely due to something with your environment not being able to run puppeteer.

Hi. As pointed out correctly by @N-D-P the issue is that the required dependencies are not installed for ubuntu. I followed his path and got it working. Below is the command that you can use. To install chromium

sudo apt-get install chromium-browser

Install the dependencies.

sudo apt-get install ca-certificates fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

use const client = new Client({ puppeteer: { headless: true,args: [‘–no-sandbox’, ‘–disable-setuid-sandbox’]}, session: sessionCfg });

use const client = new Client({ puppeteer: { headless: true,args: [‘–no-sandbox’, ‘–disable-setuid-sandbox’]} });

No one? help us, pls!

use const client = new Client({ puppeteer: { headless: true,args: [‘–no-sandbox’, ‘–disable-setuid-sandbox’]}, session: sessionCfg });

doesn’t work for me. I’m using the lib on EC2 linux. Version: 1.15.3

Great !! Happy Coding 😉 @uthx

This solution worked for EC2 linux server

  1. Install Cromium-browser.

    sudo apt-get install chromium-browser

  2. Install other dependencies required for ubuntu sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 li-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 li libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev

NOTE : As whatsapp-web.js is constantly upgrading, by the time you replicate this steps you may need to install some more dependencies apart from mentioned in Step 2. Just copy that dependency and stackoverflow it you will surely get its solution.

Same error here. I found that if I add this buildpack to Heroku repo, it works but the slug size increase over 350mb:

heroku buildpacks:add https://github.com/jontewks/puppeteer-heroku-buildpack.git

And this is the only way I can deploy to Heroku and run the client at this moment:

const client = new Client({
    session: sessionData,
    puppeteer: {
        headless: true,
        args: ['--no-sandbox']
    }
});