gpt4 book ai didi

node.js - 错误 : Failed to launch the browser process! Whatsapp web js | Azure 门户 Linux puppeteer 师

转载 作者:行者123 更新时间:2023-12-02 06:16:43 33 4
gpt4 key购买 nike

我正在尝试使用Whatsapp web js它在我的本地主机中工作正常,但是当我尝试推送 Azure Linux 托管时,我收到此错误。

/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 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7e190a17531d1f130e1f171910531319130a3e4f504e504f" rel="noreferrer noopener nofollow">[email protected]</a>~start: Failed to exec start script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aacddec387c9cbc7dacbc3cdc487c7cdc7deea9b849a849b" rel="noreferrer noopener nofollow">[email protected]</a> start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6700130e4a04060a17060e00094a0a000a13275649574956" rel="noreferrer noopener nofollow">[email protected]</a> 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

我的包 json 文件如下:

Node > 16.0 
NPM > 8.0
whatsapp-web.js": "^1.15.8"
"puppeteer": "^12.0.1"

最佳答案

根据非 GUI 环境的文档,例如LinuxUbuntu 等,您必须遵循一些步骤才能使 puppeteer 正常工作。设置:

  1. 首先确保您的软件包是最新的。 sudo apt-get update

  2. 然后安装一些额外的软件包

$ 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

  • 现在您需要指定一些参数来启动浏览器。启动时添加此 agr --no-sandbox还添加--disable-setuid-sandbox如果你没有root权限。你的代码应该看起来像 -
  • index.js

    new Client({
    ...,
    puppeteer: {
    args: [
    '--no-sandbox',
    '--disable-setuid-sandbox'
    ],
    authStrategy: // what ever authStrategy you are using
    }
    })
  • 是的,你已经完成了!
  • 关于node.js - 错误 : Failed to launch the browser process! Whatsapp web js | Azure 门户 Linux puppeteer 师,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72995651/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com