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

"file" argument must be a non-empty string #104

Open
ganesh143143 opened this issue Jan 3, 2019 · 3 comments
Open

"file" argument must be a non-empty string #104

ganesh143143 opened this issue Jan 3, 2019 · 3 comments

Comments

@ganesh143143
Copy link

error: Uncaught exception occured, TypeError: "file" argument must be a non-empty string TypeError: "file" argument must be a non-empty string
at normalizeSpawnArguments (child_process.js:380:11)
at exports.spawn (child_process.js:493:38)
at Object.exports.execFile (child_process.js:209:15)
at D:\Projects\EXA\emd_development\node_modules\phantom-html-to-pdf\lib\dedicatedProcessStrategy.js:47:34
at D:\Projects\EXA\emd_development\node_modules\graceful-fs\graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:149:20)

@pofider
Copy link
Owner

pofider commented Jan 4, 2019

Please take a look at what is sent here.
The first argument should be a path to the phantomjs. Is it properly installed?

@ganesh143143
Copy link
Author

I used like this

const htmlPDF = require('phantom-html-to-pdf')({
'numberOfWorkers': 2,
'tmpDir': TEMP_DIR,
'strategy': "dedicated-process",
'phantomPath': require('phantomjs-prebuilt').path
});

As per node https://www.npmjs.com/package/phantomjs is renamed to phantom-prebuilt . So i used the phantom prebuilt.

htmlPDF({ html}, ( error, pdf ) => {
if ( error ) {
reject({'message': Unable to create file ${fileName}, error});
}
else {
const {
path: tmpPath
} = pdf.stream;

   const fileStream = fs.createWriteStream(fileName);
   pdf.stream.pipe(fileStream);

}})

Please help me what is wrong in my code

@pofider
Copy link
Owner

pofider commented Jan 7, 2019

Based on the error require('phantomjs-prebuilt').path is not producing valid path.
Try to debug it.

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

2 participants