Maguy IB
Maguy IB

Reputation: 175

MacOS: How to install puppeteer with or without Chromium?

I am trying to install puppeteer globally on macOS (Mojave) 10.14.3

  1. First failure (in sudo su mode): npm install -g puppeteer
> [email protected] install /usr/local/lib/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r624492! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/puppeteer/.local-chromium'
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/usr/local/lib/node_modules/puppeteer/lib/helper.js:108:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/puppeteer/install.js:64:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/local/lib/node_modules/puppeteer/.local-chromium' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2019-02-27T14_04_04_609Z-debug.log
  1. Second failure: I successfully installed manually Chromium from https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/635943/ and then (in sudo su mode):

npm get | grep PUPPETEER

PUPPETEER_EXECUTABLE_PATH = "/Applications/Chromium.app/Contents/MacOS/Chromium"
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true
PUPPETEER_EXECUTABLE_PATH = "/Applications/Chromium.app/Contents/MacOS/Chromium"
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = true

npm install -g puppeteer

> [email protected] install /usr/local/lib/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r624492! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
{ Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/puppeteer/.local-chromium'
  -- ASYNC --
    at BrowserFetcher.<anonymous> (/usr/local/lib/node_modules/puppeteer/lib/helper.js:108:27)
    at Object.<anonymous> (/usr/local/lib/node_modules/puppeteer/install.js:64:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/local/lib/node_modules/puppeteer/.local-chromium' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/root/.npm/_logs/2019-02-27T14_07_19_001Z-debug.log

What am I doing wrong here?

Upvotes: 0

Views: 10788

Answers (2)

Chuong Tran
Chuong Tran

Reputation: 3441

Try with it:

npm config set user 0
npm config set unsafe-perm true
npm install -g puppeteer

Option unsafe-perm:

Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.

Upvotes: 8

Jamie Hill
Jamie Hill

Reputation: 23149

This was working fine for me a matter of days ago, but am not getting exactly the same error

Upvotes: 0

Related Questions