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

Spawn Error - Windows 10 #127

Open
Samerkassem opened this issue Nov 12, 2019 · 2 comments
Open

Spawn Error - Windows 10 #127

Samerkassem opened this issue Nov 12, 2019 · 2 comments

Comments

@Samerkassem
Copy link

I have:

this.wkhtmltopdf = async function () {
    try {
        console.log("createpdf")
        var response = await $http({
            url: '/wkhtmltopdf',
            method: "POST",
            responseType: 'blob',
            data:{"b":"XXX"}
        });

        if (response.status != 200) {
            this.message = this.gs("downloadFailed", "There was an error downloading the file");
            return;
        }

        var blob = new Blob([response.data], { type: 'application/*' });
        saveAs(blob, 'test.pdf');
    } catch (err) {
        $window.alert('There was an error in getting the file');
    }
};

It is installed in package:

"wkhtmltopdf": "^0.3.4"

I have installed the tool from their official website as recommended by SO users in other threads, and in the official npm:
https://www.npmjs.com/package/wkhtmltopdf

From https://wkhtmltopdf.org/downloads.html#stable

I have this PATH in my environment variables, both User and System vars enter image description here

And STILL getting this error on my machine, but on cloud it's working:

C:\Users\Samer\Desktop\ALL fineon projects\azure-fineon-webapp-fo\node_modules\wkhtmltopdf\index.js:161
    throw new Error(err); // critical error
    ^

Error: Error: spawn wkhtmltopdf ENOENT
    at ChildProcess.<anonymous> (C:\Users\xxx\Desktop\ALL xxprojects\azure-xx-webapp-fo\node_modules\wkhtmltopdf\index.js:161:11)
    at Object.onceWrapper (events.js:286:20)
    at ChildProcess.emit (events.js:198:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
    at onErrorNT (internal/child_process.js:415:16)

So what else to do?

@Samerkassem Samerkassem changed the title Spawn Error Spawn Error - Windows 10 Nov 12, 2019
@Domuska
Copy link

Domuska commented Mar 20, 2020

I ran into the very same issue. Looking at the older discussion in here, a very hacky workaround (I guess okay for very short term if you're doing development on windows machine) is to do what's described here (#29).

In a nutshell, you can change the node_modules/wkhtmltopdf/index.js the variable wkhtmltopdf.command to be the full path to the executable binary instead of just attempting to spawn wkhtmltopdf. This could be fixed in a much smarter way on the library side, but if this is blocking your work temporarily that's at least a workaround.

This might be related to the issue: nodejs/node#12986

@yurks
Copy link
Contributor

yurks commented Feb 27, 2021

#133 will stop process termination in such cases

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

3 participants