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?
This is great example how to correctly setup react-pdf with NextJS.
However, as mentioned in comments, you still get
SyntaxError: Unexpected token '||='with a node version below 15, so you need to upgrade to >=15.0.Then it works as expected.