question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"export 'EventBus' was not found in 'pdfjs-dist/lib/web/ui_utils'

See original GitHub issue

Before 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
srachnercommented, Nov 2, 2020

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

const nodeModulesLoader = environment.loaders.get('nodeModules')
if (!Array.isArray(nodeModulesLoader.exclude)) {
    nodeModulesLoader.exclude = (nodeModulesLoader.exclude == null)
        ? []
        : [nodeModulesLoader.exclude]
}
nodeModulesLoader.exclude.push(/pdfjs-dist/)
0reactions
TeemuKoivistocommented, Apr 13, 2021

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.

import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist/es5/build/pdf'
import * as pdfjsWorker from 'pdfjs-dist/es5/build/pdf.worker.entry'
import { EventBus, PDFViewer } from 'pdfjs-dist/es5/web/pdf_viewer'
import {
  PDFDocumentLoadingTask,
  PDFDocumentProxy,
  // eslint-disable-next-line import/no-unresolved
} from 'pdfjs-dist/types/display/api'

And you probably have to patch the types by yourself too:

declare module 'pdfjs-dist/es5/build/pdf' {
  export * from 'pdfjs-dist'
}
declare module 'pdfjs-dist/es5/build/pdf.worker.entry'
declare module 'pdfjs-dist/es5/web/pdf_viewer'
Read more comments on GitHub >

github_iconTop Results From Across the Web

vue js passing data through global event bus not working
Using vue cli I have created a simple vue app with two nested components. I want to pass data between them clicking the...
Read more >
Using event bus in Vue.js to pass data between components
The solution: Event bus​​ We're going to create an event bus instance as a separate file, import it into the two components that...
Read more >
How To Create a Global Event Bus in Vue 2 - DigitalOcean
You will need to create the event bus and export it somewhere so other modules and components can use it. First, create a...
Read more >
Events API | Vue 3 Migration Guide
Component instances no longer implement the event emitter interface. ... eventBus.js const eventBus = new Vue() export default eventBus.
Read more >
Vue.js: why event bus is bad idea - Lukasz Tkacz Blog
It's a pattern to achieve very common thing: transform data not only from ... eventBus.js import Vue from 'vue' export const eventBus =...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found