elliotblackburn / mdpdf

Markdown to PDF command line app with support for stylesheets
https://npmjs.com/package/mdpdf
Apache License 2.0
711 stars 46 forks source link

SyntaxError: The requested module 'cheerio' does not provide an export named 'default' #195

Closed pierreguillot closed 2 months ago

pierreguillot commented 2 months ago

I use mdpdf in Github Action on Ubuntu 22.04.4 LTS. I install mdpdf using npm install mdpdf -g and since yesterday, it generates an error:

file:///opt/hostedtoolcache/node/20.16.0/x64/lib/node_modules/mdpdf/src/utils.js:5
import cheerio from 'cheerio';
       ^^^^^^^
SyntaxError: The requested module 'cheerio' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.16.0
...

Here is the full log.

It seems that the Cheerio dependency has been updated recently to v1.0.0 and this breaks mdpdf. How Cheerio must be imported and used has changed as announced in the release. This could be related to this issue https://github.com/cheeriojs/cheerio/issues/3988.

pgalbavy-itrs commented 2 months ago

Same here, I have had to stop creating PDF docs from my MD for now. I am not a node/npm person, is there anyway to (easily) specify dependency versions and effectively rollback the dependency from latest to something that worked?

elliotblackburn commented 2 months ago

Hey, sorry about this - I don't use mdpdf too much myself so haven't come up against this yet. Yeah it looks like they release the official 1.0.0 which has caused problems. I don't have time for a full upgrade now, so I'll ping at the prior release candidate and look at pushing that out. Then if I, or someone else, gets a chance they can do the upgrade.

elliotblackburn commented 2 months ago

I've pinned the version and run it all locally and it seems to work just fine now. I've cut a release as 3.0.4 - if someone could confirm whether or not this works for them that would be much appreciated! Sorry for the issues on this one :(

pgalbavy-itrs commented 2 months ago

I can confirm that using:

npm install --verbose --global git+https://github.com/elliotblackburn/mdpdf.git#3.0.4

in my Dockerfile resolves the issue. Look forward to a full release.

Thanks!

pierreguillot commented 2 months ago

Idem. The release 3.0.4 solves the problem. Here is the log. Thank you!

elliotblackburn commented 2 months ago

Great thanks both, I'll close this for now and at some point we can move it to 1.0.0 and do another release. Sorry for any pain this has caused you!