使用部署应用程序时出现以下错误react-snap
到赫罗库。
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 日志:
> [email protected] /cdn-cgi/l/email-protection postbuild /tmp/build_3cc3bffa_
> react-snap
✅ crawled 1 out of 1 (/)
完毕!我很开心。
解决方案:
- 转到 Heroku 设置 -> 构建包 -> 添加构建包
- Add: https://github.com/jontewks/puppeteer-heroku-buildpack.git https://github.com/jontewks/puppeteer-heroku-buildpack.git
重要的 !!!确保这是第一个。这是常见的错误。
当在 Heroku 上制作 React 时,你已经(我想)已经有了https://github.com/mars/create-react-app-buildpack.git https://github.com/mars/create-react-app-buildpack.git但react-buildpack应该是第二个。没有人说。
- 重新部署并享受乐趣。
Note:经过一番努力,我对我的应用程序做了一些更改(但是,我认为这并不是很重要)
- 在 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
...
}
-
Heroku 堆栈:heroku-18 。这是默认设置,除非您的应用程序很旧,否则您将拥有它。
-
我没有这些行:
"cacheAjaxRequests": true,
"inlineCss": true,
"http2PushManifest": true,
我听说过“inlineCSS”:正确,可能会引起问题
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)