puppeteer: npm install -g puppeteer fails
npm install -g puppeteer
returns the following error: Download failed: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/puppeteer/.local-chromium'
Is this expected? I am using it as a dependency of a project I would like to install globally and this is blocking that.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 28
- Comments: 26 (5 by maintainers)
Commits related to this issue
- Fix to allow global Puppeteer install: https://github.com/GoogleChrome/puppeteer/issues/375#issuecomment-363466257 — committed to enovatedesign/php-craft by mtwalsh 6 years ago
- Update Dockerfile Found a [similar problem](https://github.com/GoogleChrome/puppeteer/issues/375#issuecomment-363466257) with a solution. — committed to robertdebock/docker-revealmd by robertdebock 6 years ago
- Fix: npm installation error in jsonresume build see https://github.com/GoogleChrome/puppeteer/issues/375 — committed to olbat/dockerfiles by olbat 6 years ago
- Fix: npm installation error in jsonresume build see https://github.com/GoogleChrome/puppeteer/issues/375 — committed to olbat/dockerfiles by olbat 6 years ago
- Install Puppeteer's dependencies Note that Puppeteer itself is not installed by this Dockerfile, since it shoud be installed in a project local directory. Also, it is so problematic to install Puppet... — committed to Maki-Daisuke/toaru-analytics by Maki-Daisuke 5 years ago
This command ended up working for me, in case anyone lands here by googling the error:
sudo npm install -g puppeteer --unsafe-perm=true
While
sudo npm install -g puppeteer --unsafe-perm=true
might work (and kudos for working it out BTW). I don’t think we can say the issue is closed. At best we can say “The issue has been dodged by setting an unsafe flag”. It would be better if the install could be done in a proper, safe way.it’s throwing the error because
mkdir '/usr/local/lib/node_modules/puppeteer/.local-chromium'
should bemkdir -p '/usr/local/lib/node_modules/puppeteer/.local-chromium'
the
.local-chromium
directory it’s trying to make is going into the/usr/local/lib/node_modules/puppeteer/
folder, which doesn’t exist at the time it’s running that command.Try with:
sudo su
sudo npm i puppeteer
(or with-g
) Yeah, both times with “sudo”.You shouldn’t install things globally because they are dependencies. Packages when you install will install all of their dependencies internally. Only install things globally when you use them in your OS level tooling. And even then, quite a bit of tools like eslint and stylelint are well thought through in most tools to not need global installs of them.
You’d need to do
sudo
here though if you really wanted to do it, because/usr
requires elevated permission to read/write to. But once again, don’t do this. It’s bad for your health later in life.After trying
sudo npm install puppeteer --unsafe-perm=true
I still get the following error?On Debian, any idea how to deal?
If someone does not work, use
npm@4.6.1
and it will work. (In my case it worked perfectly.)I believe this is an issue with permissions via NPM. I’m also using nvm with node 8.11.3 LTS, and npm 6.3.0 on a Mac.
@kat-whittenburg 's solution was what worked for me, as it bypasses the permissions. I was doing this locally however, so it still works if you omit the global flag.
sudo npm install puppeteer --unsafe-perm=true
.Thank you @kat-whittenburg !
Not a permanent fix, as I still run into permission errors on other packages (I’ve tried reseting everything, and I think it may have to do with using your fingerprint as a user access), but it works for individual items!