React-pdf: Module not found: Error: Can't resolve 'babel-runtime/regenerator'

Created on 29 Nov 2018  路  12Comments  路  Source: wojtekmaj/react-pdf

Hi,

I'm facing build error propably due to babel versions conflict.

This is output from Webpack:

ERROR in ./node_modules/pdfjs-dist/lib/web/ui_utils.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\Users\******\repos\la_client\node_modules\pdfjs-dist\lib\web'
 @ ./node_modules/pdfjs-dist/lib/web/ui_utils.js 29:19-55
 @ ./node_modules/pdfjs-dist/lib/web/pdf_link_service.js
 @ ./node_modules/react-pdf/dist/LinkService.js
 @ ./node_modules/react-pdf/dist/Document.js
 @ ./node_modules/react-pdf/dist/entry.js

I found this issue https://github.com/mozilla/pdf.js/issues/10280 so if I get it right this will be fixed with new version of pdfjs-dist.
But according to info/issues on react-pdf project it seems that for some people it is already working now with pdfjs-dist 2.0.943. Is there any additional step to make this working?

Environment

  • React-PDF version: 4.0.0
  • React version: 16.6.3
  • Webpack version: 4.26.1

Regards
Michal

bug

All 12 comments

I guess you could npm i babel-runtime or yarn add babel-runtime in the meantime, which would add the missing module and stop the error from happening. I updated pdfjs-dist to Babel 7 in mozilla/pdf.js#10293. Babel 6 or 7 though, doesn't really matter, I think this means babel-runtime is required by pdfjs-dist and as such should be listed in dependencies.

For the time being, babel-runtime may be listed as React-PDF dependency to prevent that error from happening.

I notified Mozilla about missing dependency in mozilla/pdf.js#10280.

I have a similar issue. If I add babel-runtime manually it causes an issue with duplicate packages because there is babel-runtime/regenerator and @babel/runtime/regenerator. My build only succeeded when I went into pdfjs and manually pasted the path to my @babel/runtime/regenerator. I think the less hacky hack would be to use webpack aliasing to resolve the right runtime-regenerator, but I can't figure that out.

I guess I'm wondering if there's some other way to address this.

Hi all,
this should be fixed with the next minor release (after 4.0.1)
We're waiting for Mozilla to release pdf.js 2.1.x (mozilla/pdf.js#10416) to have this fixed.
Thanks for your patience.

Thanks @wojtekmaj. We encountered the same issue today and did npm i --save-dev babel-runtime. The problem was resolved.

We also experienced same issue today. Using npm i --save-dev babel-runtime fixes the problem, but is it the best way to work around it?

@allanchua101 _that_ is the best way to work around it ;) Mozilla is about to release a new version of PDF.js though, so this workaround should no longer be needed soon.

All, React-PDF 4.0.3 is out and should have this issue resolved.

I still have the error with React-PDF 4.0.3. Only now, I can't silence it anymore by adding babel-runtime as a dependency. This makes 4.0.3 unusable and have to stick with 4.0.2 and the babel-runtime workaround.

@benabbon Is the original error mentioned the exact error you're getting, or it mentions @babel/runtime?

@wojtekmaj I created a seperate issue #361 with more details, the error I get is :
Module not found: Can't resolve '@babel/runtime/regenerator'

** My error :

This dependency was not found:

  • babel-runtime/regenerator in ./node_modules/pdfjs-dist/lib/web/ui_utils.js

To install it, you can run: npm install --save babel-runtime/regenerator

** after I run the commad => npm i --save-dev babel-runtime

It works for me

Was this page helpful?
0 / 5 - 0 ratings