错误代码1:
error while loading shared libraries: libXcomposite.so.1: cannot open shared
解决方案:
-
在项目Chrome所在的目录例如:
/home/code/puppeteer/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/
中运行ldd chrome | grep not
-
依赖库
yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 -y
错误代码2:
Running as root without --no-sandbox is not supported.
解决方案:
- 在puppeteer的launch中设置
puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox']
})
既可搞定