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

Most upvoted comments

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 be mkdir -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?

npm WARN engine puppeteer@1.12.2: wanted: {"node":">=6.4.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine mime@2.4.0: wanted: {"node":">=4.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine https-proxy-agent@2.2.1: wanted: {"node":">= 4.5.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
npm WARN engine agent-base@4.2.1: wanted: {"node":">= 4.0.0"} (current: {"node":"0.10.29","npm":"1.4.21"})
\
> puppeteer@1.12.2 install /volume1/projects/node_modules/puppeteer
> node install.js

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! puppeteer@1.12.2 install: `node install.js`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the puppeteer@1.12.2 install script.
npm ERR! This is most likely a problem with the puppeteer package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls puppeteer
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 4.4.59+
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "puppeteer" "--unsafe-perm=true"
npm ERR! cwd /volume1/projects
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /volume1/projects/npm-debug.log
npm ERR! not ok code 0

On Debian, any idea how to deal?

sudo npm i npm@4 -g

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!