centos7中puppeteer的相关错误处理

    技术2022-07-10  144

    1.error while loading shared libraries: libatk-bridge-2.0.so.0

    解决:yum install at-spi2-atk -y

    2.error while loading shared libraries: libXss.so.1

    解决:yum install libXScrnSaver* -y

    3.error while loading shared libraries: libgtk-3.so.0

    解决:yum install gtk3 -y

    在安装完成后,我们可以到安装目录下的chrome-linux/chrome去查看那些依赖未安装。比如我的这个目录在/usr/local/vue-pdf/vue-pdf/node_modules/_puppeteer@2.1.1@puppeteer/.local-chromium/linux-722234中,我可以切换到该目录中,并查看。

    cd /usr/local/vue-pdf/vue-pdf/node_modules/_puppeteer@2.1.1@puppeteer/.local-chromium/linux-722234/chrome-linux ## 查看 ldd chrome | grep not

    4.[0701/103031.227465:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported

    解决:配置启动项

    browser = await puppeteer.launch({ args: ['--no-sandbox'], headless: true });
    Processed: 0.013, SQL: 9