Puppeteer Chrome Installation

by | May 13, 2025 | IT Tips | 0 comments

I'm using Browsershot which uses Puppeteer & Chromium to generate PDF's

When you install Puppeteer by default the chromium instance is installed to $HOME/.cache/puppeteer/chrome-headless-shell/linux-127.0.6533.88 and $HOME/.cache/puppeteer/chrome/linux-127.0.6533.88

1
2
3
4
# intall chromium using install.mjs
node_modules/puppeteer/install.mjs
Chrome (127.0.6533.88) downloaded to /home/wms/.cache/puppeteer/chrome/linux-127.0.6533.88
chrome-headless-shell (127.0.6533.88) downloaded to /home/wms/.cache/puppeteer/chrome-headless-shell/linux-127.0.6533.88

This might NOT be what you want particularly if you want to maintain separate production and test environments which may have different Puppeteer and Chromium versions

To change the location of where puppeteer installs chromium add a puppeteer.config.js script next to your package.json file as follows:

1
2
3
4
5
6
7
8
9
10
11
// /var/www/wms/puppeteer.config.js
const { join } = require('path');
 
/**
 *  @type {import("puppeteer").Configuration}
 *  
 */
module.exports = {
    // Changes the cache location for Puppeteer.
    cacheDirectory: join(__dirname, 'puppeteer'),
};

Whenever puppeteer is used it will know where to find chromium

To trigger an install or re-install of chromium use the install.mjs script located under node_modules/puppeteer

1
2
3
4
5
node node_modules/puppeteer/install.mjs
Downloading chrome-headless-shell 127.0.6533.88 - 110.2 MB [====================] 100% 0.0s
Downloading chrome 127.0.6533.88 - 161.5 MB [====================] 98% 0.4s chrome-headless-shell (127.0.6533.88) downloaded to /var/www/wms/puppeteer/chrome-headless-shell/linux-127.0.6533.88
Downloading chrome 127.0.6533.88 - 161.5 MB [====================] 100% 0.0s
Chrome (127.0.6533.88) downloaded to /var/www/wms/puppeteer/chrome/linux-127.0.6533.88

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.