最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - SyntaxError: Unexpected token '||=' - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question edited Jun 7, 2022 at 2:41 Ethan 9928 gold badges18 silver badges30 bronze badges asked Jun 6, 2022 at 19:44 OrlandoOrlando 1161 silver badge7 bronze badges 6
  • 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
  • wele to front-end, you may start with reading github./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
 |  Show 1 more ment

1 Answer 1

Reset to default 7

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

发布评论

评论列表(0)

  1. 暂无评论