Studiosity / grover

A Ruby gem to transform HTML into PDFs, PNGs or JPEGs using Google Puppeteer/Chromium
MIT License
945 stars 109 forks source link

Grover::Error - SyntaxError: Unexpected token '?'` #250

Open karekauan opened 3 months ago

karekauan commented 3 months ago

I'm migrating the pdfs from the Prawn system to Grover, but when trying to run the basic example:

 grover = Grover.new('https://google.com', format: 'A4')
 pdf = grover.to_pdf
 send_data(
     pdf,
     filename: 'test.pdf',
     type: 'application/pdf',
     disposition: 'attachment'
 )

I received the following error on the line 2:

Grover::Error - SyntaxError: Unexpected token '?'

The versions used are:

Is there any incompatibility with any of these versions?

abrom commented 3 months ago

No, but you'll want to check the NODE version you're using.. I think you'll find it's one that is very very out of date (that does not support safe navigators ie < v14).

Note, Puppeteer 22.15.0 wants node v20.8.4+ 😉

JennsiS commented 2 months ago

Had the same issue with:

It was working before, and now stop working

abrom commented 2 months ago

The above error is specific to Node versions that don't support the safe navigator operator (ie < v14). It may be that you have multiple node versions installed on your system?

You can validate this by trying to call to node from within your ruby environment. eg:

%x{node -v}