alanshaw / markdown-pdf

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

TypeError: Bad argument #112

Open mdeforge opened 7 years ago

mdeforge commented 7 years ago

When I do "markdown-pdf -o test.pdf test.md", I get this.

TypeError: Bad argument at TypeError (native) at ChildProcess.spawn (internal/child_process.js:289:26) at exports.spawn (child_process.js:380:9) at Object.exports.execFile (child_process.js:143:15) at WriteStream. (C:\Program Files\nodejs\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:515:14) at endWritable (_stream_writable.js:525:3) at WriteStream.Writable.end (_stream_writable.js:490:5)

Granted, I used npmbox to build an offline installer for this. But if I'm missing something, I'd really like to know what. Don't deal with node.js and npm stuff everyday. Any clues would be helpful.

ibaned commented 7 years ago

I installed markdown-pdf by first installing NPM via the Mac OS package on their website, and then simply running

npm install markdown-pdf

I also get a similar error:

(node:74342) Warning: Possible EventEmitter memory leak detected. 2 end listeners added. Use emitter.setMaxListeners() to increase limit
internal/child_process.js:289
  var err = this._handle.spawn(options);
                         ^

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:289:26)
    at exports.spawn (child_process.js:380:9)
    at Object.exports.execFile (child_process.js:143:15)
    at WriteStream.<anonymous> (/Users/daibane/src/omega_h/doc/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:515:14)
    at afterWrite (_stream_writable.js:389:3)
    at onwrite (_stream_writable.js:379:7)
anko commented 7 years ago

Having trouble reproducing this. This works for me:

$ uname
Linux
$ node --version
v7.10.0
$ cd $(mktemp --dir)
$ npm i markdown-pdf
[ ... npm output ... ]
$ ./node_modules/.bin/markdown-pdf -o test.pdf <(echo '# hi')
[ ... markdown-pdf output ... ]

@mdeforge Are you also on Mac OS?

renhongxu123 commented 7 years ago

Hey folks, I met the same trouble on MacOS, and I find this

markdown-pdf requires phantomjs-prebuilt https://github.com/Medium/phantomjs/issues/533

And it works for me