Skip to content

Instantly share code, notes, and snippets.

@rishabhrpg
Last active December 31, 2023 09:12
Show Gist options
  • Save rishabhrpg/4025ff5da4f0159af1850cb358279e57 to your computer and use it in GitHub Desktop.
Save rishabhrpg/4025ff5da4f0159af1850cb358279e57 to your computer and use it in GitHub Desktop.
Run puppeteer inside termux

Run Puppeteer inside termux

Assumptions

  • You have termux installed and have sufficient permissions
  • You have loggedin as root user
  • You are okay with running Puppeteer inside a container (Alpine)

Gotchas

  • There is no build of Google Chrome available for ARM at this moment, so using chromium instead.
  • Installing chromium on Termux directly requires snap which is another big hurdle so alternively using alpine distro here.

Steps

proot-distro install alpine
proot-distro login alpine
apk update && apk add --no-cache nmap && \
  echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
  echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
  apk update && \
  apk add --no-cache \
  chromium
git clone https://github.com/rishabhrpg/puppeteer-on-termux.git
cd puppeteer-on-termux
yarn
node index.js
  • If you see a message "screenshot saved" then puppeteer is successfully configured to run on termux
  • Use repo puppeteer-on-termux as starting point as it has correct args included to sucesfully run chromium on termux

This tutoraial has been moved here [https://github.com/rishabhrpg/puppeteer-on-termux]

@mauro199304
Copy link

Error: Failed to launch the browser process! spawn /root/puppeteer-on-termux/node_modules/puppeteer/.local-chromium/linux-818858/chrome-linux/chrome ENOENT
I have this error when executing the test script that comes in the repository.

@iamstarcode
Copy link

@mauro199304 I experienced the same problem, just wondering if you founf a solityion to this error ENOENT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment