nft: `phantomjs-prebuilt` does not work

Attached is a zip for a project that uses phantomjs-prebuilt, and results in an error such as:

Error: spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT

Reproducible in now dev as well. When I take a look at the file path “node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs” the file is indeed not there, so perhaps the detection mechanism isn’t including the binary into the output results.

odc.zip

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Me too!! @JuanM04 any luck?? I’m trying to fix this with html-pdf.

It only happens in vercel server, it works perfect on the development server.

Error creating PDF Error: spawn ./node_modules/phantomjs/bin/phantomjs ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn ./node_modules/phantomjs/bin/phantomjs',
  path: './node_modules/phantomjs/bin/phantomjs',
  spawnargs: [ '/var/task/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js' ]
}

I happens to me with html-pdf

html-pdf: Received the exit code '1'
Error executing phantom at /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
Error: spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
events.js:287
      throw er; // Unhandled 'error' event
      ^

Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed
    at doWrite (_stream_writable.js:399:19)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Socket.ondata (_stream_readable.js:695:22)
    at Socket.emit (events.js:310:20)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
Emitted 'error' event on Socket instance at:
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at Socket.onerror (_stream_readable.js:729:7)
    at Socket.emit (events.js:310:20)
    at errorOrDestroy (internal/streams/destroy.js:108:12)
    at onwriteError (_stream_writable.js:418:5)
    at onwrite (_stream_writable.js:445:5)
    at doWrite (_stream_writable.js:399:11)
    at writeOrBuffer (_stream_writable.js:387:5)
    at Socket.Writable.write (_stream_writable.js:318:11)
    at Socket.ondata (_stream_readable.js:695:22) {
  code: 'ERR_STREAM_DESTROYED'
}

Same thing here.

Issue still exists

Error: spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs 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: -2,
  code: 'ENOENT',
  syscall: 'spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs',
  path: '/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs',
  spawnargs: [
    '--local-url-access=false',
    '/var/task/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js'
  ]
}
2022-08-17T19:23:41.824Z	92d59458-9985-4a35-b013-aeeca8e85b44	ERROR	Uncaught Exception 	{"errorType":"TypeError","errorMessage":"Cannot read properties of undefined (reading 'pipe')","stack":["TypeError: Cannot read properties of undefined (reading 'pipe')","    at /var/task/.next/server/chunks/1950.js:861:16","    at /var/task/node_modules/html-pdf/lib/pdf.js:60:21","    at respond (/var/task/node_modules/html-pdf/lib/pdf.js:141:14)","    at ChildProcess.onError (/var/task/node_modules/html-pdf/lib/pdf.js:149:46)","    at ChildProcess.emit (node:events:527:28)","    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)","    at onErrorNT (node:internal/child_process:478:16)","    at processTicksAndRejections (node:internal/process/task_queues:83:21)"]}
Unknown application error occurred

This issue hasn’t been fixed.

Error: spawn /usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:480:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -2, code: ‘ENOENT’, syscall: ‘spawn /usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs’, path: ‘/usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs’, spawnargs: [ ‘–local-url-access=false’, ‘/usr/src/app/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js’ ] }

@eg-delacruz I didn’t fix it, decided to write a python api just for mailing pdfs.

Same thing here.

Issue still exists

Error: spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs 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: -2,
  code: 'ENOENT',
  syscall: 'spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs',
  path: '/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs',
  spawnargs: [
    '--local-url-access=false',
    '/var/task/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js'
  ]
}
2022-08-17T19:23:41.824Z	92d59458-9985-4a35-b013-aeeca8e85b44	ERROR	Uncaught Exception 	{"errorType":"TypeError","errorMessage":"Cannot read properties of undefined (reading 'pipe')","stack":["TypeError: Cannot read properties of undefined (reading 'pipe')","    at /var/task/.next/server/chunks/1950.js:861:16","    at /var/task/node_modules/html-pdf/lib/pdf.js:60:21","    at respond (/var/task/node_modules/html-pdf/lib/pdf.js:141:14)","    at ChildProcess.onError (/var/task/node_modules/html-pdf/lib/pdf.js:149:46)","    at ChildProcess.emit (node:events:527:28)","    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)","    at onErrorNT (node:internal/child_process:478:16)","    at processTicksAndRejections (node:internal/process/task_queues:83:21)"]}
Unknown application error occurred

I also still get the same issue here… @RobzLegz , did you manage to fix it?

Problem still exists

I’m having the same problem using HTML-PDF two days trying to solve this and nothing

I am still unable to use phantomjs-prebuilt with Now.sh.

Here are the errors:

error: Could not spawn [/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs] executable. Please make sure phantomjs is installed correctly.
error: undefined {"errno":"ENOENT","code":"ENOENT","syscall":"spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs","path":"/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs","spawnargs":["--local-url-access=false","/var/task/node_modules/phantom/dist/shim/index.js"]}
RequestId: 1ab2f546-b7e6-48d0-9d88-a4645a55d71b Error: Runtime exited with error: exit status 1
Runtime.ExitError

And a simplistic test case: test-phantomjs-serverless.zip