react-pdf: TypeError: key.split(...).at is not a function

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

Building into nextjs project here.

After running npm i react-pdf -P, and attempting npm run build, I experience the error in the title. Is there a previous version I should roll back to?

Steps to reproduce

install, build with nextjs

Expected behavior

expect a successful build

Actual behavior

Build error occurred TypeError: key.split(…).at is not a function at new KeyboardManager (/node_modules/pdfjs-dist/build/pdf.js:4213:43)

Additional information

No response

Environment

  • Browser (if applicable): chrome, latest
  • React-PDF version: 6.2.2
  • React version:17.0.2
  • Webpack version (if applicable): not using webpack

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 20 (5 by maintainers)

Most upvoted comments

install corejs and add this:

import ‘core-js/features/array/at’;

image `core-js` cannot fix my question. I had to manually write a compatible writing method

Just a heads up that this error also comes up from PDF.js itself now (rather than just the worker), so adding the polyfill is the only real solution. The core-js fix is working fine for me, it just needs to be imported before react-pdf.

app-pdf error

“react-pdf”: “^6.2.2”, “core-js”: “^3.29.1”

You can see the attached screenshot. let me know if i am doing anything wrong with it…

I write similarly to you, but I don’t seem to have encountered your problem.

My component: https://github.com/chongqiangchen/unowai-frontend/blob/main/src/ui/widgets/pdf/index.tsx

Where I import the core: https://github.com/chongqiangchen/unowai-frontend/blob/main/src/pages/_app.tsx