Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chromium revision is not downloaded #13

Closed
DennisKh opened this issue Apr 8, 2019 · 13 comments
Closed

Chromium revision is not downloaded #13

DennisKh opened this issue Apr 8, 2019 · 13 comments

Comments

@DennisKh
Copy link

DennisKh commented Apr 8, 2019

(node:14878) UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install"
at Launcher.launch (/usr/local/lib/node_modules/puppeteer-pdf/node_modules/puppeteer/lib/Launcher.js:119:15)
at <anonymous>
(node:14878) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14878) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
@speeddragon
Copy link
Contributor

Hi DennisKh, can you provide more information ? Did you run npm i puppeteer-pdf -g ? Normally when installing puppeteer-pdf it will download the chromium browser.

@DennisKh
Copy link
Author

DennisKh commented Apr 9, 2019

After npm i puppeteer-pdf -g I got this error. There was an error before that:

[error] Task #PID<0.922.0> started from #PID<0.920.0> terminating
** (stop) :enoent
    :erlang.open_port({:spawn_executable, '/var/www/elixir/elixir_billing/deps/puppeteer_pdf/lib/puppeteer_pdf'}, [:use_stdio, :exit_status, :binary, :hide, {:args, ["/var/www/elixir/elixir_billing/lib/elixir_billing_web/templates/bank_cards/index2.html", "--path", "/var/www/elixir/elixir_billing/index.pdf", "--marginLeft", "40", "--marginRight", "40", "--marginTop", "40", "--marginBottom", "150", "--format", "A4", "--printBackground", "--displayHeaderFooter", "--debug"]}])
    (elixir) lib/system.ex:641: System.cmd/3
    (puppeteer_pdf) lib/generate.ex:179: anonymous fn/2 in PuppeteerPdf.Generate.from_file/3
    (elixir) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: #Function<1.83883354/0 in PuppeteerPdf.Generate.from_file/3>
    Args: []
[error] Ranch protocol #PID<0.920.0> of listener ElixirBillingWeb.Endpoint.HTTP (connection #PID<0.919.0>, stream id 1) terminated
** (exit) :enoent

When I installed the puppeteer-pdf, I saw how the chromium was installed

@speeddragon
Copy link
Contributor

:enoent means that it couldn't found the puppeteer_pdf binary. With the -g it would be installed globally, something like /usr/local/bin/puppeteer-pdf. Please check where it was installed.

@DennisKh
Copy link
Author

DennisKh commented Apr 10, 2019

I fixed error with :enoent but I still have error with chromium

@speeddragon
Copy link
Contributor

For some reason, the new version of the puppeteer-pdf (the node dependency) doesn't download Chromium. I'm checking why it doesn't ...

@speeddragon
Copy link
Contributor

speeddragon commented Apr 10, 2019

Installing an older version seems to fix the issue, npm i --save puppeteer@1.2.0 -g but don't know why it doesn't download chromium in the new version (1.4.0).

Ok, appears to be in a separate package, https://github.com/GoogleChrome/puppeteer#puppeteer-core.

I will update readme to let people know how to use the new version.

@speeddragon
Copy link
Contributor

Not sure if the comment above solved the issue, but you should copy the .local-chromium folder from the puppeteer to inside the puppeteer-pdf. Something like this.

cp -R puppeteer/.local-chromium/ /usr/local/lib/node_modules/puppeteer-pdf/node_modules/puppeteer/

You can run find / -name ".local-chromium" to find where it is.

@DennisKh
Copy link
Author

Thank you very much for the detailed instructions. Everything works. But I need advice. How to connect css file? I tried to prescribe styles in the html but they did not render.

@speeddragon
Copy link
Contributor

Not sure I understand what is your issue. I've used with in-line styling (not really sure why right now), but I've tested with a html file and a css file and it works.

index.html

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="style.css" />
  </head>
  <body>
    <h1>H1</h1>
    <p>Hello there</p>
  </body>
</html>
body {
  font-weight: bold;
  font-size: 50px;
}

puppeteer-pdf index.html --path xpto.pdf

speeddragon added a commit that referenced this issue Apr 11, 2019
Update readme to reflect issues #12 and #13
@DennisKh
Copy link
Author

I got with this. It was not a issue. It was my mistake when i tried to render view.

@speeddragon
Copy link
Contributor

Don't know yet why the behaviour of this bug, but another solution is to remove the puppeteer folder inside the node_modules folder that is inside of puppeteer-pdf. If you install both puppeteer and puppeteer-pdf you don't need that one inside puppeteer-pdf.

@crashingstatic
Copy link

I am still having this problem installing puppeteer-pdf with sudo npm i puppeteer-pdf -g on Ubuntu 18.04 (Beaver). Installing puppeteer with sudo npm i puppeteer -g afterwards downloaded chromium, but then threw UnhandledPromiseRejectionWarning: Error: Chromium revision is not downloaded. Run "npm install" or "yarn install" when I tried using puppeteer-pdf

@speeddragon
Copy link
Contributor

Did you try copy the .local-chromium folder as explained here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants