"export 'EventBus' was not found in 'pdfjs-dist/lib/web/ui_utils'
See original GitHub issueBefore you start - checklist
- I have read documentation in README
- I have checked sample and test suites to see real life basic implementation
- I have checked if this question is not already asked
What are you trying to achieve? Please describe.
I am working in rails 6 app and within rails 6 app i’m creating one of my module in react and in that module i’m using react-pdf library but somehow i’m getting this error when i’m importing react-pdf components from react-pdf library:
ERROR in ./node_modules/react-pdf/dist/esm/eventBus.js
"export 'EventBus' was not found in 'pdfjs-dist/lib/web/ui_utils'
i’m getting above error when i wrote like this
import {Document, Page, pdfjs} from 'react-pdf';
but i’m not getting error when i wrote like this
const pdfjs = require('pdfjs-dist/es5/build/pdf');
i have also tried to create a separate react app from scratch and follow the getting started example and it is working perfectly in react app Any idea guys where i’m going wrong?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top GitHub Comments
I had the same issue and managed to get it working by excluding the pdfjs-dist folder from babel transpilation through adding the following to my environment.js file, as described here
Having the unfortunate job of fixing this problem and since this thread seems to come up first in the Google results, I’ll just post my own fix here. So what happened was the pdfjs stopped supporting es5 (see https://github.com/mozilla/pdf.js/issues/13190) out of the box and now you have to do a little dance to keep your code es5 compatible. Eg.
And you probably have to patch the types by yourself too: