I installed Puppeteer some time ago for my Node.js application that was deployed on Heroku. I used the Heroku CLI tools for deployment. Now I want to get rid of Puppeteer entirely. I already deleted it from my package.json and ran npm install again. However when I try to commit my changes to GitHub, it keeps including the Chromium browser files that Puppeteer downloaded. These files are massive and GitHub rejects them because they exceed the file size limits. How can I completely remove all Puppeteer files including the browser binaries from my project? I need to clean everything so my repository goes back to normal size.
Start by running git ls-files | grep chromium or git ls-files | grep puppeteer to identify any cached files that may have mistakenly been committed to your repository. It’s crucial that these binaries aren’t included in your version control. Ensure your .gitignore file has entries for node_modules/ and .cache/ directories to prevent tracking these files in the future. If Git is already tracking them, you’ll need to untrack them using git rm --cached -r node_modules/.cache/puppeteer/ before your next commit. Lastly, verify that your package-lock.json file has been updated following the removal of Puppeteer from package.json. In my case, addressing this issue involved clearing the npm cache and regenerating the package-lock.json from scratch, which resolved lingering references to heavy packages.
Check for a .puppeteerrc.json or .puppeteerrc.js file in your project root - these can override where Puppeteer stores browser downloads and might be pointing to locations outside node_modules. Look through your Heroku deployment logs too. Sometimes the buildpack downloads Chromium during builds even after you’ve removed Puppeteer from dependencies. You might need to remove any Puppeteer-related buildpacks from your app config. I hit the same issue migrating away from Puppeteer in production. What fixed it for me: completely deleted my local git clone and re-cloned from GitHub after confirming the remote was clean. This wiped out any local cache or temp files that weren’t being tracked properly. Then I rebuilt everything fresh with the new dependencies.
You’ve got Chromium binaries that Puppeteer cached in your node_modules folder and probably in your git history. Here’s the fix:
Clear the Puppeteer cache:
npm cache clean --force
rm -rf node_modules
npm install
If those massive files got committed to git, remove them from your history:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch -r node_modules/.cache/puppeteer' --prune-empty --tag-name-filter cat -- --all
Then force push to GitHub:
git push origin --force --all
Honestly though, this whole mess could’ve been avoided with better automation. Instead of installing heavy browser dependencies locally, run your browser automation in the cloud.
I switched to Latenode for all my browser automation. No more Puppeteer installations, no more massive Chromium downloads, no more Heroku buildpack headaches. Everything runs in their cloud.
Your code stays clean, deployments are faster, and you don’t have to deal with browser binary management. Plus it scales automatically.
check for any .cache folders lying around - puppeteer sometimes dumps chromium in random spots outside node_modules. run find . -name '*chromium*' -o -name '*puppeteer*' to track down leftover binaries. your .gitignore might be missing some entries too.
Puppeteer’s a pain because it dumps Chromium binaries everywhere. Even after you delete it from package.json, those browser files hang around in hidden cache folders.
Find all the leftover junk:
find . -type d -name '.local-chromium' -o -name '.cache' | grep -v node_modules
Also check ~/.cache/puppeteer in your home folder and delete it.
To clean up git history completely:
git filter-repo --path-glob '**/chromium*' --invert-paths
git filter-repo --path-glob '**/.local-chromium*' --invert-paths
Honestly though, browser automation is a nightmare. You spend more time dealing with cache cleanup and binary management than actually coding.
I switched everything to Latenode. No local Chromium, no cache mess, no bloated repos. Just clean code that hits their cloud browsers.
Keeps deployments lightweight and you never deal with browser binaries again.