Puppeteer installation has error

Viewed 16920

I have problem with puppeteer. I cannot install it on my debian 8.7.1. These are the steps:

1.install chrome:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get -f install
sudo dpkg -i google-chrome-stable_current_amd64.deb

2.install nodejs & puppeteer:

apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | bash -
sudo apt-get install -y nodejs
npm i puppeteer

When I run npm i puppeteer, the errors are:

> puppeteer@0.11.0 install /root/node_modules/puppeteer
> node install.js

ERROR: Failed to download Chromium r499413! Set "PUPPETEER_SKIP_CHROMIUM_DOWNLOAD" env variable to skip download.
Error: Download failed: server returned code 403. URL:  https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/499413 /chrome-linux.zip
at ClientRequest.https.get.response (/root/node_modules/puppeteer/utils/ChromiumDownloader.js:195:21)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at HTTPParser.parserOnIncomingClient (_http_client.js:565:21)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
at TLSSocket.socketOnData (_http_client.js:454:20)
at emitOne (events.js:115:13)
at TLSSocket.emit (events.js:210:7)
at addChunk (_stream_readable.js:266:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! puppeteer@0.11.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the puppeteer@0.11.0 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!     /root/.npm/_logs/2017-10-04T12_32_37_607Z-debug.log

I run the command npm config set PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true to skip download but it wants to download chromium yet.

Any idea to solve this problem?

8 Answers

Try below options;

1) npm config set puppeteer_skip_chromium_download true
2) Add puppeteer_skip_chromium_download=true to .npmrc file where the package.json location

After that run sudo npm install --unsafe-perm=true --allow-root

References;

https://github.com/GoogleChrome/puppeteer/issues/2270
https://medium.com/forcit/seo-for-single-page-applications-8543619e1d0c

upgrade your puppeteer version (optional)

npm set strict-ssl false

npm config set puppeteer_skip_chromium_download true

and npm install again.

try sudo npm install puppeteer --unsafe-perm=true

Error: spawn EACCES

This roughly means that puppeteer cannot execute Chrome due to permissions issues. If you're having troubles I have a docker image here that you can use and interact with remotely. The issue with Chrome and many linux distros is that installation is quite a challenge to solve.

I faced a similar issue when I was using Puppeteer. I see two parts to your problem, 1. The inability to download Chromium and getting 403 error other is 2. Error: spawn EACCES problem

I'll start with Error: spawn EACCES problem as it's more subtle and tricky

This is because your debian machine doesn't have the required dependencies installed in order to run Puppeteer. These dependencies differ between distributions(CentOS, Ubuntu/Debian etc...).

Follow these steps,

  1. Install all the dependencies required. You can refer this link for the list, https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
  2. After all the dependencies are installed, install npm and configure proxy in .npmrc if you are behind a VPC/proxy.
  3. Then, as usual, go ahead with npm i puppeteer and proceed as always

Next to address your inability to download Chromium problem.

Are you behind a proxy? That was my issue.

I noticed on executing npm i puppeteer the script downloads Chromium from an external URL which from your log is https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/499413/chrome-linux.zip

npm is unable to download from this external URL because of the proxy blocking it. The way I solved this issue was by configuring .npmrc file with the proxy settings

npm config set proxy http://<proxy_username>:<proxy_passowrd>@<proxy_host>:<proxy_port>

npm config set https-proxy http://<proxy_username>:<proxy_passowrd>@<proxy_host>:<proxy_port>

Note:

  1. If your username/password contains any special characters you need to URL encode them. Eg. If your username is bruce\wayne then you need to URL encode it as bruce%5Cwayne where %5C="\"
  2. If your proxy has no authentication then ignore and

Examples:

npm config set proxy http://bruce%5Cwayne:darkknight@11.434.2.23:8080

npm config set https-proxy http://bruce%5Cwayne:darkknight@11.434.2.23:8080

So, try configuring your .npmrc file using the commands given above and then try running npm i puppeteer. The proxy will no longer be blocking the external URL and you would be able to download Chromium.

Let me know if this works and reach out to me if you have any doubts.

I have faced similar issue. The best work around for this is to create a project using npm init, then install puppeteer using command "npm install puppeteer --save". This way chromium also gets installed with out any issues.Hope this helps..

Please set the following in .npmrc puppeteer_download_host = https://npm.taobao.org/mirrors

or

npm config set puppeteer_download_host https://npm.taobao.org/mirrors

Related