Open FlorianLoch opened 4 years ago
Getting same error on windows
Same error for me today on macOS Catalina
Same error for me on Ubuntu
Unfortunately same error for me on Catalina (10.15.3) today.
Command: markdown-pdf PeakSpotting-csv-changes.md
.
markdown-pdf
installed globally.
This tool looks very promising, hopefully, we will be able to resolve this issue! 💪
by providing the current directory argument it worked for me. -c ./
-c doesn't work for me. Which version are you using? I just dropped to v9.0.0 and is working fine with any arguments.
Same issue here on macos Mojave 10.14.6, I tried markdown-pdf v9.0.0 and v10.0.0
$ markdown-pdf readme.md
$ markdown-pdf -c ./ readme.md
Same error but line 117
internal/validators.js:117
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received null
at validateString (internal/validators.js:117:11)
at normalizeSpawnArguments (child_process.js:406:3)
at spawn (child_process.js:542:16)
at Object.execFile (child_process.js:232:17)
at WriteStream.<anonymous> (/opt/local/lib/node_modules/markdown-pdf/index.js:117:22)
at WriteStream.emit (events.js:333:22)
at finishMaybe (_stream_writable.js:687:14)
at _stream_writable.js:664:5
at WriteStream._final (internal/fs/streams.js:311:3)
at callFinal (_stream_writable.js:657:10) {
code: 'ERR_INVALID_ARG_TYPE'
This may be related to #181
Checking the code in index.js
I found my opts.phantomPath
was empty on line 117.
PhantomJS is required to render the PDF so you must have it installed on your system and markdown-pdf
must be told where it is.
The solution In #142 almost worked for me but npm would not install phantomjs-prebuilt properly I am not an expert in js or npm so I chose to copy it over manually.
sudo npm install -g phantomjs-prebuilt
In my case the above fails but leaves the zip download in /tmp
Inside the zip is the bin
folder with thephantomjs
binary.
We can call markdown-pdf
and tell it to use this binary with the -p
option.
I chose to copy it next to the existing phantom/render.js
file under the npm installed markdown-pdf folder:
sudo cp phantomjs /opt/local/lib/node_modules/markdown-pdf/phantom/
By calling markdown-pdf with the -p option (tells it where to find phantomjs) it works!
markdown-pdf readme.md -p /opt/local/lib/node_modules/markdown-pdf/phantom/phantomjs
You could hardcode this so you don't have to call it with the -p option every time. Just be aware this is considered bad practice as your changes will be overwritten.
In markdown-pdf/index.js above line 117 add the path to phantomjs
- in my case:
opts.phantomPath = '/opt/local/lib/node_modules/markdown-pdf/phantom/phantomjs';
I hope this helps until the PhantomJS install issue can be resolved.
This answer from #181 worked for me on Ubuntu 18.04:
markdown-pdf -p $(which phantomjs) mymarkdown.md
Windows:
Error: ENOENT: no such file or directory...
Maybe add phantomjs
as a requirement?
This answer from #181 worked for me on Ubuntu 18.04:
markdown-pdf -p $(which phantomjs) mymarkdown.md
great, you need to install phantomjs first, run command: "npm install -g phantomjs" then look for the phantomjs installed path: "which phantomjs" last run convert command: "markdown-pdf -p /home/xxxxx/phantomjs test.md"
Hello, just updated and tried to use it again with very simple invocation:
markdown-pdf doc.md
I expected a
doc.pdf
to be created. Instead I got the following error message:Aside it created an empty
doc.pdf
file, also indicating that it's not a permission issue on my system. I am using macOS Catalina.Cheers, Florian