[BUG]
Describe the bug How to fix this. when run react I found error. ./node_modules/pdfjs-dist/build/pdf.js 3454:145 Module parse failed: Unexpected token (3454:145) File was processed with these loaders:
- ./node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders. | numPages: this._numPages, | annotationStorage: (annotationStorage === null || annotationStorage === void 0 ? void 0 : annotationStorage.serializable) || null,
filename: ((_this$_fullReader = this._fullReader) === null || _this$_fullReader === void 0 ? void 0 : _this$_fullReader.filename) ?? null
| }).finally(() => { | if (annotationStorage) {
How to Reproduce Steps to reproduce the behavior:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots
Please add screenshots to help explain your problem.

PDF File Please attach the pdf file.
Details (please complete the following information):
- Device: [e.g. Desktop, iPhone6, Pixel2]
- OS: [e.g. Windows 10, Ubuntu 18.04, iOS8.1, Android Pie]
- Browser [e.g. stock browser, safari, chrome]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
@hendras1722 can you share the version of library and version of its peer dependency pdfjs-dist
The below solution works for me First, install npm install npm-force-resolutions --save-dev
Then in package.json we need to override the pdfjs-dist version to previous working version like this
"dependencies": { "pdf-viewer-reactjs": "2.2.3", }. "scripts": { "preinstall": "npx npm-force-resolutions" }, "resolutions": { "pdfjs-dist": "2.6.347" } and in scripts section add new preinstall entry:
"preinstall": "npx npm-force-resolutions", now if you do npm install and run your application it should work. Hope it helps
The root cause of the problem is , though in the dependency package.json has version 2.6.347 for pdfjs-dist since ^ was there before the version number during npm install, it installs the most recent version of pdfjs-dist which is causing this problem.