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 [email protected]~start: Failed to exec start script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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"
3
Answers
Whatsapp-web.js is highly unstable .Please try to uninstall whatsapp-web.js dependency from package.json and reinstall it again.
Install updates
Install Chromium-browser.
Install other dependencies required for ubuntu
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
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:
First make sure your packages are up to date.
sudo apt-get update
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
--no-sandbox
also add--disable-setuid-sandbox
if you don’t have root privilege. Your code shoule loook like –index.js
it only works best on windows.
solution:
use windows initialize the project (create your own boiler plate)
steps:
incase of chromium issue :
if all is successfull, transfer whatapp_bot folder together with its node_modules to linux ubuntu computer
it worked for me 💯 💯 💯