kohheepeace / docusaurus-pdf

Generate PDF for docusaurus
https://drive.google.com/file/d/19P3qSwLLUHYigrxH3QXIMXmRpTFi4pKB/view
113 stars 18 forks source link

"npx docusaurus-pdf" downloads Chromium browser everytime it is executed #13

Closed krillboi closed 4 years ago

krillboi commented 4 years ago

Not sure if this is a problem on the plugin's side, but everytime I execute npx docusaurus-pdf it starts downloading the Chromium browser again. Since this takes about a minute, the turn around time for testing the pdf output is a little long.

npx docusaurus-pdf from-build doc/touchgfx-doc/build docs/introduction/welcome /
Downloading Chromium r722234 - 134.7 Mb [====================] 100% 0.0s

Can anyone reproduce this?

kohheepeace commented 4 years ago

@krillboi

Is this working ?

  1. Installl docusaurus-pdf locally by yarn -D docusaurus-pdf or npm --save-dev docusaurus-pdf
  2. run yarn run docusaurus-pdf options...
krillboi commented 4 years ago

npm install --save-dev docusaurus-pdf seems to have done the trick, thanks!

joaodos3v commented 4 years ago

Hello, sorry for commenting on a closed topic (if you prefer, I open another issue).

I have the same question and even after npm install docusaurus-pdf, I still have this error:

Error: Failed to launch the browser process!
/<my-dir>/.npm/_npx/2485/lib/node_modules/mr-pdf/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/<my-dir>/.npm/_npx/2485/lib/node_modules/mr-pdf/node_modules/puppeteer/lib/Launcher.js:750:14)
    at Interface.<anonymous> (/home/joaovitorvvieira/.npm/_npx/2485/lib/node_modules/mr-pdf/node_modules/puppeteer/lib/Launcher.js:739:50)
    at Interface.emit (events.js:327:22)
    at Interface.close (readline.js:416:8)
    at Socket.onend (readline.js:194:10)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Can you confirm how is the command I should execute after installing locally, please?

kohheepeace commented 4 years ago

@joao-vieira

The below command not working ?

npm i --save-dev docusaurus-pdf
npm run docusaurus-pdf http://localhost:3000/myBaseUrl/docs/doc1 hoge.pdf

According to your error log, are you using mr-pdf not docusaurus-pdf ??

This repogitory is docusaurus-pdf.

joaodos3v commented 4 years ago

Hello @KohheePeace, thanks for your reply.

First, excuse the confusion. The reported error is correct, it was using docusaurus-pdf itself. However, I read other issues of this repo and saw your indication to use mr-pdf, so I ended up putting the wrong log. Excuse me.

Regarding your comment, I followed the steps indicated and received this output:

$ npm install --save-dev docusaurus-pdf

> puppeteer@2.1.1 install /<my-project>/node_modules/puppeteer
> node install.js

Downloading Chromium r722234 - 121.1 Mb [====================] 100% 0.0s
Chromium downloaded to /<my-project>/node_modules/puppeteer/.local-chromium/linux-722234
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ docusaurus-pdf@1.2.0
added 19 packages from 41 contributors and audited 1694 packages in 46.857s

143 packages are looking for funding
  run `npm fund` for details

found 2 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details
$  npm run docusaurus-pdf http://localhost:3000/docs/anything hoge.pdf

npm ERR! missing script: docusaurus-pdf
npm ERR!
npm ERR! Did you mean this?
npm ERR!     docusaurus

npm ERR! A complete log of this run can be found in:
npm ERR!     /<my-user>/.npm/_logs/2020-10-12T19_41_35_982Z-debug.log
kohheepeace commented 4 years ago

@joao-vieira sorry for late reply, you're correct I also encountered the same issue.

This is the solution.

In terminal

npm install --save-dev docusaurus-pdf

# You need this line
npm install puppeteer --save-dev

AND THEN

In package.json

{

  "scripts": {
     // ADD THIS LINE
    "pdf": "docusaurus-pdf https://v2.docusaurus.io/docs/"
  },

Again In terminal

npm run pdf

I hope this will solve your issue.

sorry for taking your time and troubling you.

joaodos3v commented 4 years ago

Hi @KohheePeace ! First of all, don't worry, it's not a bother, you're helping me (and I have good news)!

I executed your commands and, at first, I had the following error:

$ npm run pdf

> deafend-documentation@0.0.0 pdf /<my-dir>
> docusaurus-pdf https://v2.docusaurus.io/docs/

Error: Failed to launch the browser process!
/<my-dir>/node_modules/docusaurus-pdf/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

    at onClose (/<my-dir>/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/Launcher.js:750:14)
    at Interface.<anonymous> (/<my-dir>/node_modules/docusaurus-pdf/node_modules/puppeteer/lib/Launcher.js:739:50)
    at Interface.emit (events.js:327:22)
    at Interface.close (readline.js:416:8)
    at Socket.onend (readline.js:194:10)
    at Socket.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-project@0.0.0 pdf: `docusaurus-pdf https://v2.docusaurus.io/docs/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-project@0.0.0 pdf 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!     /<my-dir>/.npm/_logs/2020-10-15T00_19_49_375Z-debug.log

But I found the answer here! So after running sudo apt install libgtk-3-0, I managed to generate the pdf of my documentation and left an example page below! 😄

example.pdf

Thank you for your help and congratulations on the work!

kohheepeace commented 4 years ago

@joao-vieira glad to hear that 👍