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

bug: Cannot read property 'readFile' of undefined #71

Closed
razjel opened this issue Apr 13, 2020 · 2 comments
Closed

bug: Cannot read property 'readFile' of undefined #71

razjel opened this issue Apr 13, 2020 · 2 comments
Labels

Comments

@razjel
Copy link

razjel commented Apr 13, 2020

I installed fresh version and can convert even simple markdown file, because it always throws error.

  • md-to-pdf version: 3.0.1
  • platform Windows
  • node version: 9.11.2

Error that is thrown:

 md-to-pdf.cmd .\sample.md
  × generating PDF from .\sample.md
    → Cannot read property 'readFile' of undefined
{ ListrError: Something went wrong
    at tasks.then (c:\Users\razjel\AppData\Roaming\npm\node_modules\md-to-pdf\node_modules\listr\index.js:102:18)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)
  name: 'ListrError',
  errors:
   [ TypeError: Cannot read property 'readFile' of undefined
    at Object.exports.readFile (c:\Users\razjel\AppData\Roaming\npm\node_modules\md-to-pdf\dist\lib\read-file.js:13:97)
    at Object.exports.convertMdToPdf (c:\Users\razjel\AppData\Roaming\npm\node_modules\md-to-pdf\dist\lib\md-to-pdf.js:17:29)
    at Task.task (c:\Users\razjel\AppData\Roaming\npm\node_modules\md-to-pdf\dist\cli.js:107:39)
    at Promise.resolve.then.then.skipped (c:\Users\razjel\AppData\Roaming\npm\node_modules\md-to-pdf\node_modules\listr\lib\task.js:167:30)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)
    at startup (internal/bootstrap/node.js:201:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3) ],
  context: {} }
@razjel razjel added the bug label Apr 13, 2020
@razjel razjel changed the title bug: bug: Cannot read property 'readFile' of undefined Apr 13, 2020
@simonhaenisch
Copy link
Owner

simonhaenisch commented Apr 13, 2020

You need to use at least Node 10.17 or 11.14, as specified in the engines section of package.json:

md-to-pdf/package.json

Lines 17 to 19 in 53173a3

"engines": {
"node": ">=10.17 <11.0 || >=11.14"
},

I thought you'd automatically get a warning if you used a lower node version than specified in the engines field, but apparently not 🤷🏻‍♂️ I assumed that latest Node 10.x is the minimum that people would be using, since LTS is already 12.x by now, but maybe i was too quick to use the new promise-based fs API.

I'll add a fallback to use the old readFile api instead. In the meantime I suggest to update to latest Node 10.x or 12.x

@razjel
Copy link
Author

razjel commented Apr 13, 2020

Thanks for fast reply, I'll update node.

I'm using older version of node because I experimented with git subtree which apparently crashes newer node versions on bigger repositories :P

@razjel razjel closed this as completed Apr 13, 2020
simonhaenisch added a commit that referenced this issue Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants