繁体   English   中英

Heroku:puppeteer chrome:加载共享库时出错:libX11-xcb.so.1

[英]Heroku: puppeteer chrome: error while loading shared libraries: libX11-xcb.so.1

使用react-snap将应用程序部署到 Heroku 时出现以下错误。

puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory

我应用了所有更改,设置了所有构建包。

我什至可以在没有"postbuild": "react-snap"行,它可以工作。

但是,然后在这里添加行,将再次失败。 现在怎么办?

"reactSnap": {
    "cacheAjaxRequests": true,
    "inlineCss": true,
    "http2PushManifest": true,
    "puppeteerArgs": ["--no-sandbox", "--disable-setuid-sandbox"]
  }
"postbuild": "react-snap"

我在这个问题上挣扎了 4 个小时。 谷歌搜索了很多解决方案,但没有一个适合我。 最后我明白了,!! (其实就是此时此刻)

Heroku 日志:

 > individual-claims@0.1.0 postbuild /tmp/build_3cc3bffa_ > react-snap ✅ crawled 1 out of 1 (/)

完毕。 我很开心。

解决方案:

  1. Go 到 Heroku 设置 -> 构建包 -> 添加构建包
  2. 地址: https://github.com/jontewks/puppeteer-heroku-buildpack.git

重要的 !!! 确保这是第一个。 这就是通病。 在 Heroku 上进行 React 时,您已经(我想)拥有https://github.com/mars/create-react-app-buildpack.git但 react-pack 应该是第二个没人说。

  1. 重新部署并享受乐趣。

注意:经过一番挣扎后,我对我的应用程序进行了一些更改(但是我认为这并不重要)

  1. 在 package.json
     "engines": {
          "node": ">=14.12.0",  // Just to make sure I have the latest and the greatest 
          "npm": ">=6.14.8"
        },
  
   "devDependencies": {
        ...
       "prettier": "^2.1.2",   // Just to make sure I have the latest and the greatest 
        ...
   }
  1. Heroku 堆栈:heroku-18。 这是默认设置,除非您的应用程序较旧,否则您拥有它。

  2. 我没有这些行:

"cacheAjaxRequests": true,
"inlineCss": true,
"http2PushManifest": true,

我听说“inlineCss”:是的,可能会导致问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM