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

Doesn't work: internal/validators.js:125 TypeError [ERR_INVALID_ARG_TYPE] #194

Open
ElectricRCAircraftGuy opened this issue Oct 8, 2020 · 6 comments

Comments

@ElectricRCAircraftGuy
Copy link

ElectricRCAircraftGuy commented Oct 8, 2020

I'm on Ubuntu 20.04.

I saw this answer: https://superuser.com/a/902150/425838

Tried to install:

$ npm install -g markdown-pdf
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gabriel/.npm/_logs/2020-10-08T06_13_24_844Z-debug.log

Failed, so I used sudo:

It seems to have worked:

$ sudo npm install -g markdown-pdf
[sudo] password for gabriel: 
npm WARN deprecated phantomjs-prebuilt@2.1.16: this package is now deprecated
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/usr/local/bin/markdown-pdf -> /usr/local/lib/node_modules/markdown-pdf/bin/markdown-pdf

> phantomjs-prebuilt@2.1.16 install /usr/local/lib/node_modules/markdown-pdf/node_modules/phantomjs-prebuilt
> node install.js

I tried to use it. Failed!

$ markdown-pdf test.md
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:411:3)
    at spawn (child_process.js:545:16)
    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:203:15)
    at finishMaybe (_stream_writable.js:646:14)
    at stream._final (_stream_writable.js:624:5)
    at WriteStream._final (internal/fs/streams.js:268:3)
    at callFinal (_stream_writable.js:617:10)

Here's my test.md file I was trying to convert to pdf:

Snippet from: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/markdown/github_readme_center_and_align_images.md

## 1.1. Align images left, right, or centered, with NO WORD WRAP:

This:

```html
**Align left:**
<p align="left" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>

**Align center:**
<p align="center" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>

**Align right:**
<p align="right" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>
```

Produces this:

**Align left:**
<p align="left" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>

**Align center:**
<p align="center" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>

**Align right:**
<p align="right" width="100%">
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>

If you'd like to set the text itself to left, center, or right, you can include the text inside the `<p>` element as well, as regular HTML, like this:

```html
<p align="right" width="100%">
    This text is also aligned to the right.<br>
    <img width="33%" src="https://i.stack.imgur.com/RJj4x.png"> 
</p>
```
@t0stiman
Copy link

project seems to be dead, sadly

@bruce2233
Copy link

Same problem. Have you resolved?

@bing-10
Copy link

bing-10 commented Jul 25, 2022

Same problem. Have you resolved?

image

I have encountered the same problem, and I got the output PDF with nothing, which cannot be opened:
image

@alanshaw Could you give us some advice, please?

@ElectricRCAircraftGuy
Copy link
Author

ElectricRCAircraftGuy commented Jul 25, 2022

FYI all: here's my current workaround to convert markdown to PDF:

Summary of that answer: don't use markdown-pdf at all.

Instead:

  1. Use the Markdown Viewer plugin in Chrome.
  2. Use pandoc. See my answer here:
    pandoc -f gfm -t html5 --metadata pagetitle="test.md" --css github.css \
    test.md -o test.pdf

@bing-10
Copy link

bing-10 commented Jul 25, 2022

FYI all: here's my current workaround to convert markdown to PDF: https://superuser.com/a/1591372/425838

Thank you for the guidance, but I cannot find any practical solutions for this problem in the community you have provided.

@ElectricRCAircraftGuy
Copy link
Author

ElectricRCAircraftGuy commented Jul 25, 2022

@Billyshane

Thank you for the guidance, but I cannot find any practical solutions for this problem in the community you have provided.

I've updated my comment. Does it make more sense now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants