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

[BUG] #81

Open
hendras1722 opened this issue Jun 15, 2021 · 2 comments
Open

[BUG] #81

hendras1722 opened this issue Jun 15, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@hendras1722
Copy link

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:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
Please add screenshots to help explain your problem.
image

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 hendras1722 added the bug Something isn't working label Jun 15, 2021
@mdsadiq
Copy link

mdsadiq commented Aug 5, 2021

@hendras1722 can you share the version of library and version of its peer dependency pdfjs-dist

@swingtechnologies
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants