6

I need to build nextjs project with PDFViewer using @react-pdf-viewer, but when collecting page there are some error SyntaxError: Unexpected token '||='.

The problem is occured from pdf.js in node_modules, I try to change ||= to || in pdf.js, and build no error.

But I need to deploy in hosting and need to download pdf.js from yarn install, some code that I change before will be restored.

How can I solve it?

5
  • 1
    ||= is a recent addition to the language, what Node version are you using?
    – FZs
    Commented Jun 6, 2022 at 19:48
  • im using 14.17.0
    – Orlando
    Commented Jun 6, 2022 at 19:51
  • 4
    Update to >=15.0 in order to use ||=
    – FZs
    Commented Jun 6, 2022 at 19:52
  • welcome to front-end, you may start with reading github.com/mozilla/pdf.js#using-pdfjs-in-a-web-application chapter
    – Kyr
    Commented Jun 6, 2022 at 21:36
  • @FZs it works, but i chose to downgrade @react-pdf-viewer
    – Orlando
    Commented Jun 7, 2022 at 17:18

1 Answer 1

6

You get this error with version below 15, so you need to upgrade to >=15.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.