ng2-pdf-viewer: Several errors while building app with --prod flag

Bug Report or Feature Request (mark with an x)
- [ ] Regression (a behavior that used to work and stopped working in a new release)
- [x] Bug report -> please search issues before submitting
- [ ] Feature request
- [ ] Documentation issue or request

When I try to build my app for production, I get the following errors: image

I’m using the 6.3.2 version.

I’m importing it on a shared module, and exporting it to the other modules: image

Even if I don’t use it on any component/page, I get the error just from importing it.

Weird things:

  • It was working at least until last week (last successful deploy);
  • It works on Windows machines, but I get these error in Linux environments;

Searched a lot and got nothing.

Any help?

Thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 7
  • Comments: 33 (1 by maintainers)

Most upvoted comments

I got the same issue, Need to add a dependencies library, and the issue will be fixed for me. "@types/pdfjs-dist": "~2.0.1", "ng2-pdf-viewer": "^6.3.2"

OR else decrease ng2-pdf-viewer version number and add pdfjs-dist "pdfjs-dist": "~2.5.207", "ng2-pdf-viewer": "~5.3.4",

I got this error today as well.

It looks like the “latest” version of the pdfjs-dist npm went from version 2.5.207 to 2.6.347 a day ago.

Setting pdfjs-dist back to the previous version fixed the errors for me i.e. add this line to your package.json dependencies: "pdfjs-dist": "2.5.207",

I got the same issue, adding "pdfjs-dist": "2.5.207", to package.json with npm solved my issue, what I did exactly is I added this and removed the package-lock.json file and node_modules folder, then I did run npm i, that did fix my issue.

@sandu2d in yarn I think there is something called "resolutions": Try:

"resolutions": {
    "pdfjs-dist": "2.5.207"
  }

Docs: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

Fixed in version 6.4.0

I got the same issue, Need to add a dependencies library, and the issue will be fixed for me. "@types/pdfjs-dist": "~2.0.1", "ng2-pdf-viewer": "^6.3.2"

OR else decrease ng2-pdf-viewer version number and add pdfjs-dist "pdfjs-dist": "~2.5.207", "ng2-pdf-viewer": "~5.3.4",

@Rahul-kalsha You are a great visions thanks boy

@farhanramli-work Before you do your steps, which what exactly I did, did you specify or “force” package pdfjs-dist to version 2.5.207?

npm install pdfjs-dist@2.5.207 --save

You should be having this ("pdfjs-dist": "2.5.207") in your dependencies in package.json.

I tried the version 6.4.2 of ng2-pdf-viewer with angular version 8.2.14. In chrome it works fine, but when i try at firefox the error that throw me is about of zone.js and multiple messages only importing the module in any own module at project. I solved trying version by version of ng2-pdf-viewer and pdfjs-dist, the next versions it works for me at chrome and firefox: "ng2-pdf-viewer": "^5.3.4", and "pdfjs-dist": "^2.5.207", If i try only installing the ng2-pdf-viewer and automaticly this package install the dependencies will not work because the package install the pdfjs-dist of version that it not compatible with my typescript, you MUST install every package and version manually.

Good. This also worked for me

On Sun 14 Feb, 2021, 1:06 PM Khushboo Agrawal, notifications@github.com wrote:

“pdfjs-dist”: “~2.5.207”, “ng2-pdf-viewer”: “~5.3.4” This works for me

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/VadimDez/ng2-pdf-viewer/issues/715#issuecomment-778740621, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI7LCVSQBZQHHA3XHSYNCN3S654QBANCNFSM4WSUOHSA .

Follow above steps, your issue will be resolved

On Sun 14 Feb, 2021, 12:55 PM Khushboo Agrawal, notifications@github.com wrote:

Not working , I am facing the issue again

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/VadimDez/ng2-pdf-viewer/issues/715#issuecomment-778739729, or unsubscribe https://github.com/notifications/unsubscribe-auth/AI7LCVR2WIW56CKUA3H5L6LS653FRANCNFSM4WSUOHSA .

@markabrahams Thanks bro you saved my day

@farhanramli-work Oh I didn’t see the package.json file you posted, but yes as what @brainwind-software said, you need to remove ^, this will install the latest of 2.x so it will install 2.6.347, the problem in 2.6.347 and you need 2.5.207 to fix it.

@farhanramli-work You added:

"pdfjs-dist": "^2.5.207",

but you have to add:

"pdfjs-dist": "2.5.207",

And I would add it before ‘ng2-pdf-viewer’

I got this error today as well.

It looks like the “latest” version of the pdfjs-dist npm went from version 2.5.207 to 2.6.347 a day ago.

Setting pdfjs-dist back to the previous version fixed the errors for me i.e. add this line to your package.json dependencies: "pdfjs-dist": "2.5.207",

you’re my savior thank you…