markdown-pdf: The "file" argument must be of type string. Received type object

Hi,

When I run markdown-pdf README.md I get the following error:

    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
    at validateString (internal/validators.js:125:11)
    at normalizeSpawnArguments (child_process.js:414:3)
    at spawn (child_process.js:553:16)
    at Object.execFile (child_process.js:224:15)
    at WriteStream.<anonymous> (/usr/local/lib/node_modules/markdown-pdf/index.js:117:22)
    at WriteStream.emit (events.js:202:15)
    at finishMaybe (_stream_writable.js:646:14)
    at stream._final (_stream_writable.js:624:5)
    at WriteStream._final (internal/fs/streams.js:270:3)
    at callFinal (_stream_writable.js:617:10)

Can anyone suggest any solution?

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 49
  • Comments: 22

Commits related to this issue

Most upvoted comments

I get the same with node 11.11.0. Reinstall without --ignore-scripts option and worked fine.

better to do:

sudo npm uninstall -g markdown-pdf
sudo npm install -g markdown-pdf --unsafe-perm

Thanks for the --ignore-scripts tip!

Anyone else experiencing this issue, don’t forget the -g flag in npm uninstall -g markdown-pdf like I did, because the issue may persist.

After remembering the -g flag and re-installing markdown-pdf (without --ignore-scripts) it found a missing dependency in PhantomJS and installed it.

Now I’m having a separate error from PhantomJS about libssl and a missing shared object file. On to the next one! It’s worth it because I love being able to write reports in markdown and turn them into shiny PDF’s for the boss man. Thank you!

I think the install instructions need to be changed. I had the same issue on Windows 7, until I uninstalled and then re-installed without the --ignore-scripts
Perhaps this is a Windows specific problem, in which case there should be Windows specific install instructions

Hi! no luck on Ubuntu 19.04, node v10.15.2 or v11.15.0

Uninstalled with sudo npm uninstall -g markdown-pdf Installed it with: sudo npm install -g markdown-pdf --ignore-scripts

Doing: markdown-pdf doc.md outputs:

internal/validators.js:125
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
    at validateString (internal/validators.js:125:11)
    at normalizeSpawnArguments (child_process.js:399:3)
    at spawn (child_process.js:532:38)
    at Object.execFile (child_process.js:221:15)
    at WriteStream.<anonymous> (/usr/local/lib/node_modules/markdown-pdf/index.js:117:22)
    at WriteStream.emit (events.js:194:15)
    at finishMaybe (_stream_writable.js:641:14)
    at stream._final (_stream_writable.js:619:5)
    at WriteStream._final (internal/fs/streams.js:263:3)
    at callFinal (_stream_writable.js:612:10)

Thank you 😃


Edit: worked fined if not installed globally!

node v10.14.2 Uninstall and install again without --ignore-scripts resolved the issue for me as well.

better to do:

sudo npm uninstall -g markdown-pdf
sudo npm install -g markdown-pdf --unsafe-perm

Thank you, It worked like a charm.

Can’t repro… 😕

This works for me:

cd $(mktemp -d)
npm i markdown-pdf
echo '# hi' > README.md
./node_modules/.bin/markdown-pdf README.md

Also works with markdown-pdf globally installed.

Version deets:

$ node -v
v11.10.0
$ ./node_modules/.bin/markdown-pdf --version
9.0.0
$ ./node_modules/.bin/phantomjs --version
2.1.1

TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object
[...]
    at WriteStream.<anonymous> (/usr/local/lib/node_modules/markdown-pdf/index.js:117:22)

That’s here. Looks like childArgs contains something nonsensical for some reason, and childProcess.execFile throws.

Could one of you add a console.log(childArgs) before that line, so we find the culprit?