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
# 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:
// /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
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