I am trying to use puppeteer in cron service, but I keep getting this error:
Jul 24 06:47:37 PM Error: Failed to launch the browser process! spawn /usr/bin/chromium-browser ENOENT
Jul 24 06:47:37 PM
Jul 24 06:47:37 PM
Jul 24 06:47:37 PM TROUBLESHOOTING: Troubleshooting | Puppeteer
Jul 24 06:47:37 PM
Jul 24 06:47:37 PM at ChildProcess.onClose (/opt/render/project/src/node_modules/@puppeteer/browsers/lib/cjs/launch.js:277:24)
Jul 24 06:47:37 PM at ChildProcess.emit (node:events:511:28)
Jul 24 06:47:37 PM at ChildProcess._handle.onexit (node:internal/child_process:291:12)
Jul 24 06:47:37 PM at onErrorNT (node:internal/child_process:483:16)
Jul 24 06:47:37 PM at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Below are the 3 things I’ve tried.
- Error could not found chromium - #8 by jeremy-render. so I have cron-build.sh that contains:
#!/usr/bin/env bash
# exit on errorset -o errexit
# source: https://community.render.com/t/error-could-not-found-chromium/9848/2
npm install
# npm run build # uncomment if required
# Store/pull Puppeteer cache with build cache
if [ ! -d $PUPPETEER_CACHE_DIR ] ; then
echo "...Copying Puppeteer Cache from Build Cache"
cp -R $XDG_CACHE_HOME/puppeteer/ $PUPPETEER_CACHE_DIR
else
echo "...Storing Puppeteer Cache in Build Cache"
cp -R $PUPPETEER_CACHE_DIR $XDG_CACHE_HOME
fi
Note, I use [ instead of [[ because [[ is compile error when I deployed, I am not familiar with bash so I hope this is correct.
- I also followed this post: Docker: puppeteer not working on a Express (NestJS) app - #4 by Jade_Paoletta so I have the following config passed to puppeteer:
{
executablePath: '/usr/bin/chromium-browser',
headless: 'new',
slowMo: undefined
}
- I also created
. puppeteerrc.cjs
as suggested here Error could not found chromium - #9 by tomstove
NOTE:
When I ssh’ed into the service, I checked the suggested path /opt/render/project/puppeteer
and when I listed the content, I did not see puppeteer, as show below.
==> Using Node version 20.3.0 via environment variable NODE_VERSION
==> Docs on specifying a Node version: Setting Your Node.js Version | Render Docs
render@towa-cron-shell:~/project/src$ ls /opt/render/project/
nodes src
render@towa-cron-shell:~/project/src$
Please advise on how to run puppeteer.