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:

I’m using the 6.3.2 version.
I’m importing it on a shared module, and exporting it to the other modules:

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)
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 thepackage-lock.jsonfile andnode_modulesfolder, then I did runnpm i, that did fix my issue.@sandu2d in yarn I think there is something called
"resolutions": Try:Docs: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
Fixed in version 6.4.0
@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-distto version 2.5.207?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:
Follow above steps, your issue will be resolved
On Sun 14 Feb, 2021, 12:55 PM Khushboo Agrawal, notifications@github.com wrote:
@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:
but you have to add:
And I would add it before ‘ng2-pdf-viewer’
you’re my savior thank you…