gutschilla / elixir-pdf-generator

Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.
MIT License
330 stars 71 forks source link

mix deps.compile not working #85

Open iteron-yasir opened 3 years ago

iteron-yasir commented 3 years ago

I've latest nodejs version 15.14.0. I've created new phoenix project by mix phx.new hello --no-webpack. Then, I created assets folder.

  1. Inside the assets, I run npm install chrome-headless-render-pdf puppeteer. And added { :pdf_generator, ">=0.6.2", compile: "make chrome" } in mix.exs. mix deps.get pdf_generator - It's working fine mix deps.compile pdf_generator - When i run this command. I'm getting this error make: *** No rule to make target 'chrome'. Stop. ** (Mix) Could not compile dependency :pdf_generator, "make chrome" command failed. You can recompile this dependency with "mix deps.compile pdf_generator", update it with "mix deps.update pdf_generator" or clean it with "mix deps.clean pdf_generator"

  2. As mentioned ReadMD, I've changed the {:pdf_generator, "~> 0.6.2", github: "gutschilla/elixir-pdf-generator", compile: "make chrome"} it in mix.exs. After that, I've cleaned the deps and mix deps.get and I've compiled the code by mix deps.compile pdf_generator. Now, I'm getting this error make: *** No rule to make target 'config/prod.exs', needed by '_build/prod'. Stop. ** (Mix) Could not compile dependency :pdf_generator, "make chrome" command failed. You can recompile this dependency with "mix deps.compile pdf_generator", update it with "mix deps.update pdf_generator" or clean it with "mix deps.clean pdf_generator"

  3. I've tried another one method also, removed make chrome from the mix.exs as { :pdf_generator, ">=0.6.0" }. And installed chromium apt-get install -y chromium-chromedriver. Now, mix deps.compile pdf_generator was working fine. But, when i run PdfGenerator.generate(url, generator: :chrome, prefer_local_executable: true). I'm getting this error {:error, {:generator_failed, "node:internal/modules/cjs/loader:927\n throw err;\n ^\n\nError: Cannot find module '/home/yasir/hello/_build/dev/lib/pdf_generator/priv/node_modules/chrome-headless-render-pdf/dist/cli/chrome-headless-render-pdf.js'\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)\n at Function.Module._load (node:internal/modules/cjs/loader:769:27)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)\n at node:internal/main/run_main_module:17:47 {\n code: 'MODULE_NOT_FOUND',\n requireStack: []\n}\n"}}

  4. It's Working with this configuration for me. Add {:pdf_generator, "~> 0.6.2", github: "gutschilla/elixir-pdf-generator"} in to mix.exs then run mix deps.clean pdf_generator && mix deps.get pdf_generator && mix deps.compile && mix deps.compile pdf_generator install chromium apt-get install -y chromium-chromedriver I was using no-webpack project. So, I've created assets folder in root project directory cd assets and npm install chrome-headless-render-pdf puppeteer Now go back to project root directory. Go into the deps/pdf_generator/ then run make priv/node_modules. Finally, pdf generation working with this steps.

What i was doing wrong in 1,2 and 3 procedure? In 4th procedure, why i need run that make command inside the deps(Correct me, if I am doing anything wrong).

darrenklein commented 2 years ago

I can't speak to every detail of this issue, but I believe that the error noted in point 2 is a result of the removal of config/prod.exs that was introduced in https://github.com/gutschilla/elixir-pdf-generator/pull/74

gutschilla commented 2 years ago

Hey, this library is in need of an update. Will do