2

I am trying to use Whatsapp web js and it's working fine in my localhost but when I am trying to push in Azure Linux Hosting, I am getting this error.

/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241
            reject(new Error([
                   ^

Error: Failed to launch the browser process!
/node_modules/whatsapp-web.js/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory

    at onClose (/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:241:20)
    at Interface.<anonymous> (/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:231:68)
    at Interface.emit (node:events:402:35)
    at Interface.close (node:readline:586:8)
    at Socket.onend (node:readline:277:10)
    at Socket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
npm info lifecycle gti-campaign-mgmt@1.0.1~start: Failed to exec start script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gti-campaign-mgmt@1.0.1 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gti-campaign-mgmt@1.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm timing npm Completed in 105615ms

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-07-15T12_45_52_651Z-debug.log

My package json file below:

Node > 16.0 
NPM > 8.0
whatsapp-web.js": "^1.15.8"
"puppeteer": "^12.0.1"
BJ Coder
  • 350
  • 5
  • 16
  • 1
    Does this answer your question? [Puppeteer Error: error while loading shared libraries: libgobject-2.0.so.0](https://stackoverflow.com/questions/66070860/puppeteer-error-error-while-loading-shared-libraries-libgobject-2-0-so-0) – theDavidBarton Jul 15 '22 at 20:33

3 Answers3

4

As per th documentation for a non GUI environment,e.g. Linux,Ubuntu etc, you must need to follow some steps to get puppeteer working fine. Setps:

  1. First make sure your packages are up to date. sudo apt-get update

  2. Then install some additional packages

$ sudo apt install -y gconf-service libgbm-dev libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-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 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

  1. Now there is some arguments you need to specify to launch the browser. Add this agr while launching --no-sandbox also add --disable-setuid-sandbox if you don't have root privilege. Your code shoule loook like -

index.js

new Client({
    ...,
    puppeteer: {
        args: [
          '--no-sandbox',
          '--disable-setuid-sandbox'
        ],
        authStrategy: // what ever authStrategy you are using
    }
})
  1. Yep you are done !!
1

Error: Failed to launch the browser process! /node_modules/whatsappweb.js/node_modules/puppeteer/.local-chromium/linux-982053/chrome-linux/chrome: error while loading shared libraries: libgobject-2.0.so.0: cannot open shared object file: No such file or directory

Whatsapp-web.js is highly unstable .Please try to uninstall whatsapp-web.js dependency from package.json and reinstall it again.

  1. Install updates

    sudo apt-get update -y then -> sudo apt install -y libatk-bridge2.0-0 && sudo apt install -y libxkbcommon-x11-0 && sudo apt-get install -y libxdamage-dev
    
  2. Install Chromium-browser.

      sudo apt-get install chromium-browser
    
  3. 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
    

As whatsapp-web.js is continually being updated, installing more dependencies could be necessary by the time and also check with docker file build in steps which were said by @thedavidbarton.

Reference: node.js - Error: Failed to launch the browser process puppeteer - Stack Overflow

Venkatesan
  • 3,748
  • 1
  • 3
  • 15
  • Hi @VenkatesanSettu-MT it's not working but after i tried using docker there is an new error ``Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted`` – BJ Coder Jul 20 '22 at 14:59
-1

it only works best on windows.

solution:

use windows initialize the project (create your own boiler plate) steps:

mkdir whatapp_bot
cd  whatapp_bot
npm init -y
npm i whatsapp-web.js 

incase of chromium issue :

node node_modules/puppeteer/install.js

if all is successfull, transfer whatapp_bot folder together with its node_modules to linux ubuntu computer

it worked for me