pdfjs-dist npm update from 2.0.489 to 2.0.943 causes webpack error: Can't resolve 'babel-runtime/regenerator'
See original GitHub issueAfter updating our npm package for pdfjs-dist from 2.0.489 to 2.0.943, webpack fails to build. If we downgrade back to version 2.0.489 all is well again and the errors go away.
Here’s a copy of the webpack build log showing the failures:
10% building 1/1 modules 0 activei 「wds」: Project is running at http://localhost:8081/
i 「wds」: webpack output is served from /
i 「wds」: Content not from webpack is served from C:\xxxxxx\Website\dist × 「wdm」: 2471 modules
ERROR in ./node_modules/pdfjs-dist/lib/core/pdf_manager.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\core'
ERROR in ./node_modules/pdfjs-dist/lib/core/evaluator.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\core'
ERROR in ./node_modules/pdfjs-dist/lib/core/obj.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\core'
ERROR in ./node_modules/pdfjs-dist/lib/display/fetch_stream.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\display'
ERROR in ./node_modules/pdfjs-dist/lib/display/network.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\display'
ERROR in ./node_modules/pdfjs-dist/lib/display/node_stream.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\display'
ERROR in ./node_modules/pdfjs-dist/lib/display/transport_stream.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\display'
ERROR in ./node_modules/pdfjs-dist/lib/shared/message_handler.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\shared'
ERROR in ./node_modules/pdfjs-dist/lib/web/ui_utils.js
Module not found: Error: Can't resolve 'babel-runtime/regenerator' in 'C:\xxxxxx\Website\node_modules\pdfjs-dist\lib\web'
i 「wdm」: Failed to compile.
Configuration:
- Chrome: latest
- Windows 10 Professional: Latest updates
- PDF.js version: 2.0.943
- Is a browser extension: No
What is the expected behavior? (add screenshot) For the webpack build to succeed.
What went wrong? (add screenshot)
The webpack build fails, citing errors in the pdfjs-dist npm package for:
Module not found: Error: Can't resolve 'babel-runtime/regenerator'
Package.json excerpt follows:
{
...
"engines": {
"node": ">= 8.9.0"
},
"private": true,
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.1.6",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",
"clean-webpack-plugin": "^1.0.0",
"copy-webpack-plugin": "^4.6.0",
"css-loader": "^1.0.1",
"eslint": "^5.9.0",
"file-loader": "^2.0.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"http-server": "^0.11.1",
"less": "^3.8.1",
"less-loader": "^4.1.0",
"mini-css-extract-plugin": "^0.4.4",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"style-loader": "^0.23.1",
"webpack": "^4.26.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {
"@babel/polyfill": "^7.0.0",
"bootstrap": "^3.3.7",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"jquery-ui": "^1.12.1",
"moment": "^2.22.2",
"pdfjs-dist": "^2.0.943",
"popper.js": "^1.14.5",
"uuid": "^3.3.2",
"whatwg-fetch": "^3.0.0"
}
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
pdfjs-dist - npm
PDF.js is a Portable Document Format (PDF) library that is built with HTML5. Our goal is to create a general-purpose, web standards-based ...
Read more >Looking for help to make npm/pdfjs-dist work with Webpack ...
This issue seems to arise due to esModule option introduced in worker-loader@3.0.0 . The fix for this was merged in (pre-release) ...
Read more >ngx-pdf-viewer/Lobby - Gitter
Module not found: Error: Can't resolve 'zlib' in ... and I need the publication of your ng2-pdf-viewer 5.2.1 project, with the pdfjs-dist 2.0.943...
Read more >Using PDF.JS with Ionic 3.x - Saninn Salas Diaz
npm install --save pdfjs-dist@2.0.489 npm install --save-dev @types/pdfjs-dist. If you find find an unmet dependency warning UNMET PEER ...
Read more >pdfjs-dist@2.0.943 - Snyk Vulnerability Database
Does your project rely on vulnerable package dependencies? Automatically find and fix vulnerabilities affecting your projects. Snyk scans for vulnerabilities ( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@timvandermeij Babel 6 or 7, doesn’t really matter. If your code
require
s something, it should have it listed as a dependency. As such, I consider all currently released versions as faulty in that matter, and I suggest to add@babel/runtime
as a dependency ofpdfjs-dist
. Another idea is to get rid of@babel/runtime
dependency (probably the best approach). May you consider reopening this?See https://github.com/mozilla/pdfjs-dist/releases for the latest version, the other problem described here (non-updating
master
branch) is being tracked in issue #10391.That’s not what https://github.com/mozilla/pdf.js/issues/10280#issuecomment-443536299 implies; rather it just points out that if you are using https://github.com/mozilla/pdfjs-dist, then you should (in general) use the files found in the
build
andweb
folders (and not the ones in thelib
folder).