Puppeteer: Installing system dependencies requires root privileges
Installing OS system dependencies requires build-time root privileges.
Installing OS system dependencies requires build-time root privileges.
Error message
Installing system dependencies requires root privileges
How this error happens
--install-deps installs Linux OS packages, not just an npm dependency. Running that step as an unprivileged runtime user cannot install the required packages.
Run the failing command as a non-root Linux user.
npx puppeteer browsers install chrome \
--install-deps
How to fix
Install system dependencies in the privileged image-build phase, then return to an unprivileged runtime user.
USER root
RUN npx puppeteer browsers install chrome --install-deps
USER node
Things to keep in mind
This is a Dockerfile fragment for a Debian/Ubuntu-based Node image whose project already includes Puppeteer. Make the browser cache readable by the runtime user. Do not run your browser as root just to repair a build-time dependency error.