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

Several errors while building app with --prod flag #715

Closed
dionisioleonardo opened this issue Jan 26, 2021 · 33 comments
Closed

Several errors while building app with --prod flag #715

dionisioleonardo opened this issue Jan 26, 2021 · 33 comments
Milestone

Comments

@dionisioleonardo
Copy link

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.

@markabrahams
Copy link

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",

@finzero
Copy link

finzero commented Jan 26, 2021

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..

@danzrou
Copy link

danzrou commented Jan 26, 2021

Same here
@markabrahams unfortunately that doesn't solve it because it still installed pdfjs-dist under ng2-pdf-viewer separately

@hafizihamid
Copy link

Same here
@markabrahams unfortunately that doesn't solve it because it still installed pdfjs-dist under ng2-pdf-viewer separately

I only found pdfjs-dist on package-lock.json

@danzrou
Copy link

danzrou commented Jan 26, 2021

well, its probably a difference between how yarn and npm resolve dependencies.
Using npm actually did not add an additional pdfjs-dist dependency under ng2-pdf-viewer, however, yarn did

@hafizihamid
Copy link

hafizihamid commented Jan 26, 2021

well, its probably a difference between how yarn and npm resolve dependencies.
Using npm actually did not add an additional pdfjs-dist dependency under ng2-pdf-viewer, however, yarn did

noted try to installed pdfjs-dist separately, got error on importing ng2-pdf-viewer as Cannot find module 'ng2-pdf-viewer' or its corresponding type declarations.```

@danzrou
Copy link

danzrou commented Jan 26, 2021

the real solution here would be moving them from dependencies into peerDependencies and exact version

@almothafar
Copy link

almothafar commented Jan 26, 2021

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.

@hafizihamid
Copy link

hafizihamid commented Jan 26, 2021

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, remove the package-lock.json file and node_modules folder, then I did run npm i, that did fix my issue.

tried, but still got error on importing PdfViewerModule, as Cannot find module 'ng2-pdf-viewer' or its corresponding type declarations.ts(2307) in module, how did you import it in module ?

@almothafar
Copy link

almothafar commented Jan 26, 2021

@hafizihamid just like what documentations says:

import { PdfViewerModule } from 'ng2-pdf-viewer';

image

@sandu2d
Copy link

sandu2d commented Jan 26, 2021

@danzrou Did you find a solution for yarn?
Is it possible to fix depencies in a project with yarn?

In yarn.lock I have:

ng2-pdf-viewer@^6.3.2:
  version "6.3.2"
  resolved "https://registry.yarnpkg.com/ng2-pdf-viewer/-/ng2-pdf-viewer-6.3.2.tgz#07189207893ceb4c086e9b6ebd74fdbb31982af1"
  integrity sha512-H2tBhDd+Lq6CUzK2g54HsCcZDR2wTn1sDjYqKY3yF0Ydasl2R5ppCKynZBU/zge4EKvmHglJI120FbQMpJKDYQ==
  dependencies:
    "@types/pdfjs-dist" "^2.1.4"
    pdfjs-dist "^2.4.456"
    tslib "^1.10.0"

And it is installing:

pdfjs-dist@^2.4.456:
  version "2.6.347"
  resolved "https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.6.347.tgz#f257ed66e83be900cd0fd28524a2187fb9e25cd5"
  integrity sha512-QC+h7hG2su9v/nU1wEI3SnpPIrqJODL7GTDFvR74ANKGq1AFJW16PH8VWnhpiTi9YcLSFV9xLeWSgq+ckHLdVQ==

@almothafar
Copy link

@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/

@dionisioleonardo
Copy link
Author

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",

This! This solves the issue when using npm. Thank you very much @markabrahams

But it would be interesting if ng2-pdf-viewer solved it out of the box.
I'm guessing if the correct version is set on the package.json file it would fix it.

@sandu2d
Copy link

sandu2d commented Jan 26, 2021

@almothafar Yes, it worked. Thank you!

@farhanramli-work
Copy link

farhanramli-work commented Jan 27, 2021

Hi, I have folllowed all the instruction in which I have done

added "pdfjs-dist" on package.json as below

{
  "name": "project-test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-builders/custom-webpack": "^8.0.0-RC.1",
    "@angular/animations": "~10.0.4",
    "@angular/cdk": "^10.2.7",
    "@angular/common": "~10.0.4",
    "@angular/compiler": "~10.0.4",
    "@angular/core": "~10.0.4",
    "@angular/forms": "~10.0.4",
    "@angular/platform-browser": "~10.0.4",
    "@angular/platform-browser-dynamic": "~10.0.4",
    "@angular/router": "~10.0.4",
    "@fullcalendar/angular": "^5.4.0",
    "@fullcalendar/daygrid": "^5.4.0",
    "@fullcalendar/interaction": "^5.4.0",
    "@fullcalendar/list": "^5.4.0",
    "@fullcalendar/resource-timegrid": "^5.4.0",
    "cleave.js": "^1.6.0",
    "file-saver": "^2.0.5",
    "moment": "^2.24.0",
    "ng2-pdf-viewer": "^6.3.2",
    "ngx-cleave-directive": "^1.1.3",
    "ngx-extended-pdf-viewer": "^8.0.0-beta.2",
    "pdfjs-dist": "^2.5.207",
    "rxjs": "~6.5.5",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.3",
    "zxcvbn": "^4.4.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1000.3",
    "@angular/cli": "~10.0.3",
    "@angular/compiler-cli": "~10.0.4",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~3.3.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.9.5"
  }
}

importing this code on a shared module

import { PdfViewerModule } from 'ng2-pdf-viewer'

@NgModule({
  declarations: [
    AdminComponent,
    DashboardComponent,
    CreateRoleComponent,
    RoleListingComponent,
    UpdateRoleComponent,
    CreateUserComponent,
    UpdateUserComponent,
    UserListingComponent,
    AddNewLocationComponent,
    EditLocationComponent,
    OffDayComponent,
    NewHolidayComponent,
    ApplicantComponent,
    AppointmentListComponent,
    EditAppointmentComponent,
    ReportComponent,
    LocationComponent,
    StaffComponent,
    AddStaffComponent,
    EditStaffComponent,
    ResultComponent,
    ResultListComponent,
  ],
  imports: [
    CommonModule,
    AdminRoutingModule,
    SharedModule,
    ReactiveFormsModule,
    FullCalendarModule,
    FormsModule,
    PdfViewerModule,
  ],
})
export class AdminModule {}

I have

  • deleted package-lock.json file
  • deleted entire node_modules folder
  • reinstall npm

on my local upon running ng build --prod the warning message as below appear

image

don't think as a big issue as it is just warning

I am deploying this code on gitlab pipeline, and upon building pipeline, error as below appear

image

I am not sure what seems to be the problem during this build pipeline as my local seems to be working fine,

kindly help

@almothafar
Copy link

@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 [email protected] --save

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

@farhanramli-work
Copy link

@almothafar

already done the given steps

@brainwind-software
Copy link

@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'

@almothafar
Copy link

@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.

@Rahul-kalsha
Copy link

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-network
Copy link

@Rahul-kalsha The fix you have provided worked properly. Thanks for saving our lot of time.

@sraza295
Copy link

sraza295 commented Feb 2, 2021

@markabrahams Thanks bro you saved my day

@narendrasinghrathore
Copy link

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",

Not working.

@webkhushboo
Copy link

webkhushboo commented Feb 14, 2021

Not working , I am also facing the below issue

node_modules/ng2-pdf-viewer/src/app/pdf-viewer/pdf-viewer.module.d.ts:7:100 - error TS2305: Module '"../../../../pdfjs-dist/types/pdf"' has no exported member 'PDFPromise'.

7 export { PDFJSStatic, PDFDocumentProxy, PDFViewerParams, PDFPageProxy, PDFSource, PDFProgressData, PDFPromise } from 'pdfjs-dist';

@sraza295
Copy link

sraza295 commented Feb 14, 2021 via email

@webkhushboo
Copy link

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

@sraza295
Copy link

sraza295 commented Feb 14, 2021 via email

@chiragbhadani09
Copy link

chiragbhadani09 commented Feb 15, 2021

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

@VadimDez VadimDez added this to the 6.4.0 milestone Feb 16, 2021
@VadimDez
Copy link
Owner

Fixed in version 6.4.0

@AdrianMartinezCode
Copy link

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.

@fsalazarsch
Copy link

brainwind

Man, where is your adress to send you a six pack, you're my savior

@Andrea4007
Copy link

Como lo implementaste en el app.module.ts?

AdrianMartinezCódigo

@vinaytalluri4u
Copy link

Getting the following error while running npm run test
● Test suite failed to run

Cannot find module 'ng2-pdfjs-viewer' from 'src/app/shared/shared.module.ts'

Require stack:
  src/app/shared/shared.module.ts
  src/app/pages/administration/users/edit-user/edit-user.component.spec.ts

  138 | import {OktaAuthenticationService} from "./services/authentications/okta-authentication.service";
  139 | import {DocusignConfigService} from "../domain/docusign-config/docusign-config.service";
> 140 | import { PdfJsViewerModule } from 'ng2-pdfjs-viewer';
      | ^
  141 |
  142 |
  143 |

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
  at Object.<anonymous> (src/app/shared/shared.module.ts:140:1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests