marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.55k stars 544 forks source link

The answer to how to resolve Windows error of phantomjs ENOENT issue #704

Open kwen94 opened 1 year ago

kwen94 commented 1 year ago

There is no problem to operate on Linux system. However, on windoows system, has error as following:

Error: spawn D:Servicephantomjs-2.1.1-windowinphantomjs ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19) at onErrorNT (node:internal/child_process:478:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn D:Servicephantomjs-2.1.1-windows\binphantomjs', path: 'D:Servicephantomjs-2.1.1-windows\binphantomjs', spawnargs: [ '--local-url-access=false', 'E:.......\html-pdf\lib\scripts\pdf_a4_portrait.js' ] }

The Configure is const options = { height: '100000px', width: width + 'px', orientation: 'portrait', type: 'png', quality: '20', timeout: 3000, phantomPath: './node_modules/phantomjs/bin/phantomjs' };

And after I annotated the "phantomPath", it could be ok to operate!