我正在尝试使用
node.js
和 puppeteer
生成 PDF。该代码在本地 Windows 机器上运行良好。但是,当我将代码上传到 AWS Beanstalk (Linux) 时,我收到如下错误消息:
{"errors":[{"message":"无法启动浏览器进程!spawn /usr/bin/chromium ENOENT 故障排除:https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md ","位置":[{"行":3,"列":3}],"路径":["exportAllProjectChangeStatus"],"扩展名":{"代码":"INTERNAL_SERVER_ERROR"}}],"数据":{"exportAllProjectChangeStatus":null}}
我已将
chromium
作为依赖项安装在我的本地计算机和服务器中。我将我的木偶师启动设置如下;
const browser = await puppeteer.launch({
headless: true,
IgnoreHTTPSErrors: true,
executablePath: '/usr/bin/chromium',
args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu", "--ignore-certificate-errors"],});
有人可以帮我解决这个问题吗?
我相信问题出在可执行路径中。要确认,请尝试在服务器上运行
which chromium
,并将结果粘贴到 executablePath
将 EC2 连接到 ssh,然后运行以下命令:-
cd首页
cd 网络应用程序
cd.缓存
cd 傀儡师
cd 镀铬
cd linux-123.0.6312.58
cd chrome-linux64
之后运行命令:- ldd chrome | grep 不
安装以下依赖项之后:-
sudo yum install -y alsa-lib.x86_64 atk.x86_64 cups-libs.x86_64 gtk3.x86_64 ipa-gothic-fonts libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXrandr.x86_64 libXScrnSaver.x86_64 libXtst.x86_64 pango.x86_64 xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-fonts-cyrillic xorg-x11-fonts-misc xorg-x11-fonts-Type1 xorg-x11-utils