Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Can't resolve 'worker-loader' #12204

Closed
BrennanDuffey opened this issue Aug 12, 2020 · 3 comments
Closed

Module not found: Error: Can't resolve 'worker-loader' #12204

BrennanDuffey opened this issue Aug 12, 2020 · 3 comments

Comments

@BrennanDuffey
Copy link

Attach (recommended) or Link to PDF file here: Not an issue while interacting with a pdf this is a webpack error when compiling

Configuration:

  • Web browser and its version: N/A
  • Operating system and its version: Happening on a Linux box
  • PDF.js version: Issue occurs on pdfjs-dist: 2.4.456 The fix I made was using the version I originally used at 2.2.228
  • Is a browser extension: No

Steps to reproduce the problem:

  1. The import looks like this on webpack version 4.41.2
    import PDFJS from 'pdfjs-dist/webpack';

What is the expected behavior? Application compiles correctly

What went wrong? error occurs during build "Module not found: Error: Can't resolve 'worker-loader'"

It's entirely possible this is not how the pdfjs-dist was supposed to be used I ended up using that over just pdfjs since I needed it to work on IE and chrome sets up the worker for me without the dist package

@Snuffleupagus
Copy link
Collaborator

What went wrong? error occurs during build "Module not found: Error: Can't resolve 'worker-loader'"

Did you actually install the worker-loader package, since that needs to be done manually?

Does this example work, since it's not clear (to me at least) if you tried using it?


Finally, it's unlikely that anyone will be able to help without more context; hence please see https://github.com/mozilla/pdf.js/blob/master/.github/CONTRIBUTING.md (emphasis mine):

If you are developing a custom solution, first check the examples at https://github.com/mozilla/pdf.js#learning and search existing issues. If this does not help, please prepare a short well-documented example that demonstrates the problem and make it accessible online on your website, JS Bin, GitHub, etc. before opening a new issue or contacting us in the Matrix room -- keep in mind that just code snippets won't help us troubleshoot the problem.

@Maxchii
Copy link

Maxchii commented Aug 14, 2020

We're been experiencing the same issue after the latest update!

In our production build we get a o is not a constructor error on runtime.
We've tracked it down to pdfjs.GlobalWorkerOptions.workerPort = new PdfjsWorker(); in /pdfjs-dist/webpack.js.
Currently importing pdfjs-dist classes such as getDocument crashes our app on runtime.

We've made sure worker-loader is installed.

Does anyone have a workaround?

@Maxchii
Copy link

Maxchii commented Aug 14, 2020

We found our issue. We were using worker-loader 3.0.1 which is a new major version. Switching to 2.0.0 resolved our problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants