marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.55k stars 544 forks source link

Auto Configuration Failed - libproviders.so: No such file or directory #680

Closed danielmnetto closed 2 years ago

danielmnetto commented 2 years ago

I was trying to create to parse HTML to PDF Buffer in NodeJS using the following code...

pdf.create(html, { format: 'A4', header: { height: "5cm" }, footer: { height: '0.4cm' }, border: { left: '1cm', right: '1cm' } })
      .toBuffer((error, buffer) => {
          if (error) {
               console.log(error.stack)
               return res.status(500).json(null).end()
          }
}

But it returned this error:

Error: html-pdf: Unknown Error
Auto configuration failed
139921337243584:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory
139921337243584:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:
139921337243584:error:0E07506E:configuration file routines:MODULE_LOAD_DSO:error loading dso:conf_mod.c:285:module=providers, path=providers
139921337243584:error:0E076071:configuration file routines:MODULE_RUN:unknown module name:conf_mod.c:222:module=providers

    at ChildProcess.respond (/home/.../node_modules/html-pdf/lib/pdf.js:134:17)
    at ChildProcess.emit (node:events:527:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

The OS used to is Ubuntu Server 22.04 NodeJS = v16.15.0 html-pdf = v.3.0.1

It looks like the same issue of #563 from ZBilel but the difference is that the error log says libproviders.so: cannot open shared object file: No such file or directory

danielmnetto commented 2 years ago

UPDATE: I found a solution by adding an option for pdf.create which is:

childProcessOptions: {
   env: {
      OPENSSL_CONF: '/dev/null',
   },
}

With this options the code will stay like this:

pdf.create(html, {/*...*/ childProcessOptions: { env: { OPENSSL_CONF: '/dev/null' } } } )
      .toBuffer((error, buffer) => {
          if (error) {
               console.log(error.stack)
               return res.status(500).json(null).end()
          }
}

Thanks to opengeekslabap answer on the issue #531.