alanshaw / markdown-pdf

:page_facing_up: Markdown to PDF converter
https://npmjs.org/package/markdown-pdf
MIT License
2.71k stars 254 forks source link

Error: spawn EPERM and Error: spawn ENOENT #122

Open aferreira44 opened 7 years ago

aferreira44 commented 7 years ago

I'm trying to convert a markdown file to pdf with the code below of index.js and I'm getting these errors after run node index.js.

The first error below is on my Windows 10 Host Machine, and the second one is on my Ubuntu Guest VirtualBox VM.

Any idea of how to solve this?

index.js

var markdownpdf = require("markdown-pdf"),
    fs = require("fs")

markdownpdf().from("./README.md").to("./curriculo.pdf", function() {
    console.log("Converted to PDF successfully!")
})

Terminal Output Error - Windows Host VM

internal/child_process.js:319
    throw errnoException(err, 'spawn');
    ^

Error: spawn EPERM
    at exports._errnoException (util.js:1018:11)
    at ChildProcess.spawn (internal/child_process.js:319:11)
    at exports.spawn (child_process.js:378:9)
    at Object.exports.execFile (child_process.js:143:15)
    at WriteStream.<anonymous> (C:\Users\User\Documents\localdev\curriculo\node_modules\markdown-pdf\index.js:117:22)
    at emitNone (events.js:91:20)
    at WriteStream.emit (events.js:185:7)
    at finishMaybe (_stream_writable.js:512:14)
    at afterWrite (_stream_writable.js:386:3)
    at onwrite (_stream_writable.js:376:7)

Terminal Output Error - Ubuntu Guest VM

stream.js:74
      throw er; // Unhandled stream error in pipe.
      ^

Error: spawn /media/sf_localdev/curriculo/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT
    at exports._errnoException (util.js:870:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)
    at onErrorNT (internal/child_process.js:344:16)
    at nextTickCallbackWith2Args (node.js:441:9)
    at process._tickCallback (node.js:355:17)
X4mp commented 7 years ago

I got the same error as with your Ubuntu Guest VM on Arch with nodejs 8.1 and npm 4.6. I used npm install markdown-pdf to install it and node converter.js to run my converter.

converter.js:

var markdownpdf = require("markdown-pdf")

markdownpdf().from("../notes.md").to("out.pdf", function () {
  console.log("Done");
})
sneerin commented 6 years ago

same issue for any docker image i tried, starting from alpine but ubuntu is also affected

dough654 commented 5 years ago

Same issue here on MacOS Mojave

internal/streams/legacy.js:57
      throw er; // Unhandled stream error in pipe.
      ^

Error: spawn /Users/doug/OneDrive - Realogy/notes/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Same code works on Windows. And judging by an attempted spawn of "phantomjs.exe", seems like somehow it's assuming I'm on a windows machine?