<titledata-rh="true">Troubleshooting | Puppeteer</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/troubleshooting"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="2"><metadata-rh="true"property="og:title"content="Troubleshooting | Puppeteer"><metadata-rh="true"name="description"content="Chromium currently does not provide arm64 binaries for Linux. There are only"><metadata-rh="true"property="og:description"content="Chromium currently does not provide arm64 binaries for Linux. There are only"><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/troubleshooting"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/troubleshooting"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/troubleshooting"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://DVKY664LG7-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Puppeteer"href="/opensearch.xml">
<ahref="https://pptr.dev/contributing#macos-arm-and-custom-executables"target="_blank"rel="noopener noreferrer">Mac ARM with experimental support from Puppeteer</a>.</p></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="cannot-find-module-puppeteer-coreinternal"><code>Cannot find module 'puppeteer-core/internal/...'</code><ahref="#cannot-find-module-puppeteer-coreinternal"class="hash-link"aria-label="Direct link to cannot-find-module-puppeteer-coreinternal"title="Direct link to cannot-find-module-puppeteer-coreinternal"></a></h2><p>This can occur is your Node.js version is lower than 14 or you are using a
<ahref="https://github.com/puppeteer/puppeteer/issues/9121"target="_blank"rel="noopener noreferrer">https://github.com/puppeteer/puppeteer/issues/9121</a>)</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="could-not-find-expected-browser-locally"><code>Could not find expected browser locally</code><ahref="#could-not-find-expected-browser-locally"class="hash-link"aria-label="Direct link to could-not-find-expected-browser-locally"title="Direct link to could-not-find-expected-browser-locally"></a></h2><p>Starting from v19.0.0, Puppeteer will download browsers into
information.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="chrome-headless-doesnt-launch-on-windows">Chrome headless doesn't launch on Windows<ahref="#chrome-headless-doesnt-launch-on-windows"class="hash-link"aria-label="Direct link to Chrome headless doesn't launch on Windows"title="Direct link to Chrome headless doesn't launch on Windows"></a></h2><p>Some <ahref="https://support.google.com/chrome/a/answer/7532015"target="_blank"rel="noopener noreferrer">chrome policies</a> might
enforce running Chrome/Chromium with certain extensions.</p><p>Puppeteer passes <code>--disable-extensions</code> flag by default and will fail to launch
<ahref="https://github.com/puppeteer/puppeteer/issues/3681#issuecomment-447865342"target="_blank"rel="noopener noreferrer">issue 3681</a>.</p></blockquote><h2class="anchor anchorWithStickyNavbar_LWe7"id="chrome-doesnt-launch-on-linux">Chrome doesn't launch on Linux<ahref="#chrome-doesnt-launch-on-linux"class="hash-link"aria-label="Direct link to Chrome doesn't launch on Linux"title="Direct link to Chrome doesn't launch on Linux"></a></h2><p>Make sure all the necessary dependencies are installed. You can run <code>ldd chrome
| grep not</code> on a Linux machine to check which dependencies are missing. The
troubleshooting <br></li></ul></div></div></details><h2class="anchor anchorWithStickyNavbar_LWe7"id="chrome-headless-disables-gpu-compositing">Chrome headless disables GPU compositing<ahref="#chrome-headless-disables-gpu-compositing"class="hash-link"aria-label="Direct link to Chrome headless disables GPU compositing"title="Direct link to Chrome headless disables GPU compositing"></a></h2><p>Chrome/Chromium requires <code>--use-gl=egl</code> to
<ahref="https://github.com/chromium/chromium/commit/19671359ae25aa1e30bde90f8ff92453eeaac2ba"target="_blank"rel="noopener noreferrer">enable GPU acceleration in headless mode</a>.</p><divclass="language-ts codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-ts codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token keyword"style="color:#00009f">const</span><spanclass="token plain"> browser </span><spanclass="token operator"style="color:#393A34">=</span><spanclass="token plain"></span><spanclass="token keyword"style="color:#00009f">await</span><spanclass="token plain"> puppeteer</span><spanclass="token punctuation"style="color:#393A34">.</span><spanclass="token function"style="color:#d73a49">launch</span><spanclass="token punctuation"style="color:#393A34">(</span><spanclass="token punctuation"style="color:#393A34">{</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> headless</span><spanclass="token operator"style="color:#393A34">:</span><spanclass="token plain"></span><spanclass="token boolean"style="color:#36acaa">true</span><spanclass="token punctuation"style="color:#393A34">,</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> args</span><spanclass="token operator"style="color:#393A34">:</span><spanclass="token plain"></span><spanclass="token punctuation"style="color:#393A34">[</span><spanclass="token string"style="color:#e3116c">'--use-gl=egl'</span><spanclass="token punctuation"style="color:#393A34">]</span><spanclass="token punctuation"style="color:#393A34">,</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token punctuation"style="color:#393A34">}</span><spanclass="token punctuation"style="color:#393A34">)</span><spanclass="token punctuation"style="color:#393A34">;</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="chrome-is-downloaded-but-fails-to-launch-on-nodejs-14">Chrome is downloaded but fails to launch on Node.js 14<ahref="#chrome-is-downloaded-but-fails-to-launch-on-nodejs-14"class="hash-link"aria-label="Direct link to Chrome is downloaded but fails to launch on Node.js 14"title="Direct link to Chrome is downloaded but fails to launch on Node.js 14"></a></h2><p>If you get an error that looks like this when trying to launch Chromium:</p><divclass="codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-text codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token plain">(node:15505) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">spawn /Users/.../node_modules/puppeteer/.local-chromium/mac-756035/chrome-mac/Chromium.app/Contents/MacOS/Chromium ENOENT</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class
higher.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="setting-up-chrome-linux-sandbox">Setting Up Chrome Linux Sandbox<ahref="#setting-up-chrome-linux-sandbox"class="hash-link"aria-label="Direct link to Setting Up Chrome Linux Sandbox"title="Direct link to Setting Up Chrome Linux Sandbox"></a></h2><p>In order to protect the host environment from untrusted web content, Chrome uses
<ahref="https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/sandboxing.md"target="_blank"rel="noopener noreferrer">multiple layers of sandboxing</a>.
For this to work properly, the host should be configured first. If there's no
good sandbox for Chrome to use, it will crash with the error
<code>No usable sandbox!</code>.</p><p>If you <strong>absolutely trust</strong> the content you open in Chrome, you can launch
sandbox instead.</p></div></div><p>There are 2 ways to configure a sandbox in Chromium.</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="recommended-enable-user-namespace-cloning">[recommended]<!----> Enable <ahref="http://man7.org/linux/man-pages/man7/user_namespaces.7.html"target="_blank"rel="noopener noreferrer">user namespace cloning</a><ahref="#recommended-enable-user-namespace-cloning"class="hash-link"aria-label="Direct link to recommended-enable-user-namespace-cloning"title="Direct link to recommended-enable-user-namespace-cloning"></a></h3><p>User namespace cloning is only supported by modern kernels. Unprivileged user
privileges.</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token function"style="color:#d73a49">sudo</span><spanclass="token plain"> sysctl -w kernel.unprivileged_userns_clone</span><spanclass="token operator"style="color:#393A34">=</span><spanclass="token number"style="color:#36acaa">1</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h3class="anchor anchorWithStickyNavbar_LWe7"id="alternative-setup-setuid-sandbox">[alternative]<!----> Setup <ahref="https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/suid_sandbox_development.md"target="_blank"rel="noopener noreferrer">setuid sandbox</a><ahref="#alternative-setup-setuid-sandbox"class="hash-link"aria-label="Direct link to alternative-setup-setuid-sandbox"title="Direct link to alternative-setup-setuid-sandbox"></a></h3><p>The setuid sandbox comes as a standalone executable and is located next to the
once per host environment:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token comment"style="color:#999988;font-style:italic"># cd to the downloaded instance</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token builtin class-name">cd</span><spanclass="token plain"></span><spanclass="token operator"style="color:#393A34"><</span><spanclass="token plain">project-dir-path</span><spanclass="token operator"style="color:#393A34">></span><spanclass="token plain">/node_modules/puppeteer/.local-chromium/linux-</span><spanclass="token operator"style="color:#393A34"><</span><spanclass="token plain">revision</span><spanclass="token operator"style="color:#393A34">></span><spanclass="token plain">/chrome-linux/</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">sudo</span><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">chown</span><spanclass="token plain"> root:root chrome_sandbox</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">sudo</span><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">chmod</span><spanclass="token plain"></span><spanclass="token number"style="color:#36acaa">4755</span><spanclass="token plain"> chrome_sandbox</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token comment"style="color:#999988;font-style:italic"># copy sandbox executable to a shared location</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">sudo</span><spanclass="token plain"></span><spanclass="token function"style="color:#d73a49">cp</span><spanclass="token plain"> -p chrome_sandbox /usr/local/sbin/chrome-devel-sandbox</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token comment"style="color:#999988;font-style:italic"># export CHROME_DEVEL_SANDBOX env variable</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token builtin class-name">export</span><spanclass="token plain"></span><spanclass="token assign-left variable"style="color:#36acaa">CHROME_DEVEL_SANDBOX</span><spanclass="token operator"style="color:#393A34">=</span><spanclass="token plain">/usr/local/sbin/chrome-devel-sandbox</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>You might want to export the <code>CHROME_DEVEL_SANDBOX</code> env variable by default. In
this case, add the following to the <code>~/.bashrc</code> or <code>.zshenv</code>:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token builtin class-name">export</span><spanclass="token plain"></span><spanclass="token assign-left variable"style="color:#36acaa">CHROME_DEVEL_SANDBOX</span><spanclass="token operator"style="color:#393A34">=</span><spanclass="token plain">/usr/local/sbin/chrome-devel-sandbox</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-travis-ci">Running Puppeteer on Travis CI<ahref="#running-puppeteer-on-travis-ci"class="hash-link"aria-label="Direct link to Running Puppeteer on Travis CI"title="Direct link to Running Puppeteer on Travis CI"></a></h2><blockquote><p>👋 We ran our tests for Puppeteer on Travis CI until v6.0.0 (when we've
for reference.</p></blockquote><p>Tips-n-tricks:</p><ul><li><ahref="https://en.wikipedia.org/wiki/Xvfb"target="_blank"rel="noopener noreferrer">xvfb</a> service should be launched in order
to run Chromium in non-headless mode</li><li>Runs on Xenial Linux on Travis by default</li><li>Runs <code>npm install</code> by default</li><li><code>node_modules</code> is cached by default</li></ul><p><code>.travis.yml</code> might look like this:</p><divclass="language-yml codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-yml codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token key atrule"style="color:#00a4db">language</span><spanclass="token punctuation"style="color:#393A34">:</span><spanclass="token plain"> node_js</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token key atrule"style="color:#00a4db">node_js</span><spanclass="token punctuation"style="color:#393A34">:</span><spanclass="token plain"> node</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token key atrule"style="color:#00a4db">services</span><spanclass="token punctuation"style="color:#393A34">:</span><spanclass="token plain"> xvfb</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token key atrule"style="color:#00a4db">script</span><spanclass="token punctuation"style="color:#393A34">:</span><spanclass="token plain"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"></span><spanclass="token punctuation"style="color:#393A34">-</span><spanclass="token plain"> npm test</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-wsl-windows-subsystem-for-linux">Running Puppeteer on WSL (Windows subsystem for Linux)<ahref="#running-puppeteer-on-wsl-windows-subsystem-for-linux"class="hash-link"aria-label="Direct link to Running Puppeteer on WSL (Windows subsystem for Linux)"title="Direct link to Running Puppeteer on WSL (Windows subsystem for Linux)"></a></h2><p>See <ahref="https://github.com/puppeteer/puppeteer/issues/1837"target="_blank"rel="noopener noreferrer">this thread</a> with some
tips specific to WSL. In a nutshell, you need to install missing dependencies by
either:</p><ol><li><ahref="https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps#install-google-chrome-for-linux"target="_blank"rel="noopener noreferrer">Installing Chrome on WSL to install all dependencies</a></li><li>Installing required dependencies manually:
<code>sudo apt install libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2</code>.</li></ol><divclass="theme-admonition theme-admonition-caution alert alert--warning admonition_LlT9"><divclass="admonitionHeading_tbUL"><spanclass="admonitionIcon_kALy"><svgviewBox="0 0 16 16"><pathfill-rule="evenodd"d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>caution</div><divclass="admonitionContent_S0QG"><p>The list of required dependencies might get outdated and depend on what you
already have installed.</p></div></div><h2class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-circleci">Running Puppeteer on CircleCI<ahref="#running-puppeteer-on-circleci"class="hash-link"aria-label="Direct link to Running Puppeteer on CircleCI"title="Direct link to Running Puppeteer on CircleCI"></a></h2><p>Running Puppeteer smoothly on CircleCI requires the following steps:</p><ol><li>Start with a
To fix this, set <code>jest --maxWorkers=2</code> in your test command.</li></ol><h2class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-in-docker">Running Puppeteer in Docker<ahref="#running-puppeteer-in-docker"class="hash-link"aria-label="Direct link to Running Puppeteer in Docker"title="Direct link to Running Puppeteer in Docker"></a></h2><blockquote><p>👋 We used <ahref="https://cirrus-ci.org/"target="_blank"rel="noopener noreferrer">Cirrus Ci</a> to run our tests for Puppeteer
for reference. Starting from v16.0.0 we are shipping a Docker image via the
GitHub registry. The Dockerfile is located
<ahref="https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile"target="_blank"rel="noopener noreferrer">here</a> and
the usage instructions are in the
<ahref="https://github.com/puppeteer/puppeteer#running-in-docker"target="_blank"rel="noopener noreferrer">README.md</a>. The
instructions below might be still helpful if you are building your own image.</p></blockquote><p>Getting headless Chrome up and running in Docker can be tricky. The bundled
Chromium that Puppeteer installs is missing the necessary shared library
dependencies.</p><p>To fix, you'll need to install the missing dependencies and the latest Chromium
to run this Dockerfile from a webserver running on App Engine Flex (Node).</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-on-alpine">Running on Alpine<ahref="#running-on-alpine"class="hash-link"aria-label="Direct link to Running on Alpine"title="Direct link to Running on Alpine"></a></h3><p>The
<ahref="https://github.com/puppeteer/puppeteer/releases/tag/v13.5.0"target="_blank"rel="noopener noreferrer">Puppeteer v13.5.0</a>.</p><p>Example Dockerfile:</p><divclass="language-Dockerfile codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-Dockerfile codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token plain">FROM alpine</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"># Installs latest Chromium (100) package.</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">RUN apk add --no-cache \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> chromium \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> nss \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> freetype \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> harfbuzz \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> ca-certificates \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> ttf-freefont \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> nodejs \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"> yarn</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">...</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"># Tell Puppeteer to skip installing Chrome. We'll be using the installed package.</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"># Puppeteer v13.5.0 works with Chromium 100.</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">RUN yarn add puppeteer@13.5.0</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"># Add user so we don't need --no-sandbox.</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">RUN addgroup -S pptruser && adduser -S -G pptruser pptruser \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">&& mkdir -p /home/pptruser/Downloads /app \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">&& chown -R pptruser:pptruser /home/pptruser \</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">&& chown -R pptruser:pptruser /app</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"style="display:inline-block"></span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"># Run everything after as non-privileged user.</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain">USER pptruser</span><br></span><spanclass="token-line"style="color:#393A34"><spanclass="token plain"
different configuration to finally achieve success.</p><p>Usually the issue looks like this:</p><divclass="language-bash codeBlockContainer_Ckt0 theme-code-block"style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><divclass="codeBlockContent_biex"><pretabindex="0"class="prism-code language-bash codeBlock_bY9V thin-scrollbar"><codeclass="codeBlockLines_e6Vv"><spanclass="token-line"style="color:#393A34"><spanclass="token plain">Error: Failed to launch chrome</span><spanclass="token operator"style="color:#393A34">!</span><spanclass="token plain"> spawn /usr/bin/chromium-browser ENOENT</span><br></span></code></pre><divclass="buttonGroup__atx"><buttontype="button"aria-label="Copy code to clipboard"title="Copy"class="clean-btn"><spanclass="copyButtonIcons_eSgA"aria-hidden="true"><svgviewBox="0 0 24 24"class="copyButtonIcon_y97N"><pathfill="currentColor"d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svgviewBox="0 0 24 24"class="copyButtonSuccessIcon_LjdS"><pathfill="currentColor"d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>You need to patch two places:</p><ol><li>Your <code>gitlab-ci.yml</code> config</li><li>Arguments' list when launching pupepeteer</li></ol><p>In <code>gitlab-ci.yml</code> we need to install some packages to make it possible to
<code>puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] });</code>.</p><h4class="anchor anchorWithStickyNavbar_LWe7"id="tips">Tips<ahref="#tips"class="hash-link"aria-label="Direct link to Tips"title="Direct link to Tips"></a></h4><p>By default, Docker runs a container with a <code>/dev/shm</code> shared memory space 64MB.
for more details.</p><p>Seeing other weird errors when launching Chrome? Try running your container with
<code>docker run --cap-add=SYS_ADMIN</code> when developing locally. Since the Dockerfile
adds a <code>pptr</code> user as a non-privileged user, it may not have all the necessary
privileges.</p><p><ahref="https://github.com/Yelp/dumb-init"target="_blank"rel="noopener noreferrer">dumb-init</a> is worth checking out if you're
properly in some cases (e.g. in Docker).</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-in-the-cloud">Running Puppeteer in the cloud<ahref="#running-puppeteer-in-the-cloud"class="hash-link"aria-label="Direct link to Running Puppeteer in the cloud"title="Direct link to Running Puppeteer in the cloud"></a></h2><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-google-app-engine">Running Puppeteer on Google App Engine<ahref="#running-puppeteer-on-google-app-engine"class="hash-link"aria-label="Direct link to Running Puppeteer on Google App Engine"title="Direct link to Running Puppeteer on Google App Engine"></a></h3><p>The Node.js runtime of the
<ahref="https://cloud.google.com/appengine/docs/standard/nodejs/using-headless-chrome-with-puppeteer"target="_blank"rel="noopener noreferrer">the official tutorial</a>.</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-google-cloud-functions">Running Puppeteer on Google Cloud Functions<ahref="#running-puppeteer-on-google-cloud-functions"class="hash-link"aria-label="Direct link to Running Puppeteer on Google Cloud Functions"title="Direct link to Running Puppeteer on Google Cloud Functions"></a></h3><p>You can try running Puppeteer on
<ahref="https://github.com/puppeteer/puppeteer/pkgs/container/puppeteer"target="_blank"rel="noopener noreferrer">official Docker image</a>.</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-google-cloud-run">Running Puppeteer on Google Cloud Run<ahref="#running-puppeteer-on-google-cloud-run"class="hash-link"aria-label="Direct link to Running Puppeteer on Google Cloud Run"title="Direct link to Running Puppeteer on Google Cloud Run"></a></h3><p>The default Node.js runtime of
<ahref="#chrome-headless-doesnt-launch-on-unix">include the missing dependencies</a>.</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-heroku">Running Puppeteer on Heroku<ahref="#running-puppeteer-on-heroku"class="hash-link"aria-label="Direct link to Running Puppeteer on Heroku"title="Direct link to Running Puppeteer on Heroku"></a></h3><p>Running Puppeteer on Heroku requires some additional dependencies that aren't
included on the Linux box that Heroku spins up for you. To add the dependencies
on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your
app under Settings > Buildpacks.</p><p>The url for the buildpack is
<ahref="https://github.com/jontewks/puppeteer-heroku-buildpack"target="_blank"rel="noopener noreferrer">https://github.com/jontewks/puppeteer-heroku-buildpack</a></p><p>Ensure that you're using <code>'--no-sandbox'</code> mode when launching Puppeteer. This
can be done by passing it as an argument to your <code>.launch()</code> call:
<code>puppeteer.launch({ args: ['--no-sandbox'] });</code>.</p><p>When you click add buildpack, simply paste that url into the input, and click
save. On the next deploy, your app will also install the dependencies that
Puppeteer needs to run.</p><p>If you need to render Chinese, Japanese, or Korean characters you may need to
use a buildpack with additional font files like
<ahref="https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack"target="_blank"rel="noopener noreferrer">https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack</a></p><p>There's also another
<ahref="https://timleland.com/headless-chrome-on-heroku/"target="_blank"rel="noopener noreferrer">simple guide</a> from @timleland
<ahref="https://timleland.com/headless-chrome-on-heroku/"target="_blank"rel="noopener noreferrer">https://timleland.com/headless-chrome-on-heroku/</a>.</p><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-aws-lambda">Running Puppeteer on AWS Lambda<ahref="#running-puppeteer-on-aws-lambda"class="hash-link"aria-label="Direct link to Running Puppeteer on AWS Lambda"title="Direct link to Running Puppeteer on AWS Lambda"></a></h3><p>AWS Lambda <ahref="https://docs.aws.amazon.com/lambda/latest/dg/limits.html"target="_blank"rel="noopener noreferrer">limits</a>
resources that work around the issues:</p><ul><li><ahref="https://github.com/sparticuz/chromium"target="_blank"rel="noopener noreferrer">https://github.com/sparticuz/chromium</a> (a vendor and framework agnostic library that supports modern versions of <code>chromium</code>)</li><li><ahref="https://github.com/alixaxel/chrome-aws-lambda"target="_blank"rel="noopener noreferrer">https://github.com/alixaxel/chrome-aws-lambda</a> (supports up to puppeteer 10.1 - outdated)</li><li><ahref="https://github.com/adieuadieu/serverless-chrome/blob/HEAD/docs/chrome.md"target="_blank"rel="noopener noreferrer">https://github.com/adieuadieu/serverless-chrome/blob/HEAD/docs/chrome.md</a>
(serverless plugin - outdated)</li></ul><h3class="anchor anchorWithStickyNavbar_LWe7"id="running-puppeteer-on-aws-ec2-instance-running-amazon-linux">Running Puppeteer on AWS EC2 instance running Amazon-Linux<ahref="#running-puppeteer-on-aws-ec2-instance-running-amazon-linux"class="hash-link"aria-label="Direct link to Running Puppeteer on AWS EC2 instance running Amazon-Linux"title="Direct link to Running Puppeteer on AWS EC2 instance running Amazon-Linux"></a></h3><p>If you are using an EC2 instance running amazon-linux in your CI/CD pipeline,
and if you want to run Puppeteer tests in amazon-linux, follow these steps.</p><ol><li><p>To install Chromium, you have to first enable <code>amazon-linux-extras</code> which
packages.</p><h2class="anchor anchorWithStickyNavbar_LWe7"id="code-transpilation-issues">Code Transpilation Issues<ahref="#code-transpilation-issues"class="hash-link"aria-label="Direct link to Code Transpilation Issues"title="Direct link to Code Transpilation Issues"></a></h2><p>If you are using a JavaScript transpiler like babel or TypeScript, calling