Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WARNING in ./node_modules/pdfjs-dist/build/pdf.js Module not found: Error: Can't resolve 'zlib' in 'ui_angular_6\node_modules\pdfjs-dist\build'

Tags:

angular6

I was trying to migrate my angular 5 code to angular 6.

After doing npm start getting the below problem

   npm start

    WARNING in ./node_modules/pdfjs-dist/build/pdf.js
    Module not found: Error: Can't resolve 'zlib' in '\ui_angular_6\node_modules\pdfjs-dist\build'

Package.json

  "dependencies": {
    "@angular/animations": "6.0.2",
    "@angular/common": "6.0.2",
    "@angular/compiler": "6.0.2",
    "@angular/core": "6.0.2",
    "@angular/flex-layout": "^6.0.0-beta.15",
    "@angular/forms": "6.0.2",
    "@angular/http": "6.0.2",
    "@angular/platform-browser": "6.0.2",
    "@angular/platform-browser-dynamic": "6.0.2",
    "@angular/router": "6.0.2",
    "@ng-bootstrap/ng-bootstrap": "^1.1.2",
    "angular-font-awesome": "^3.1.2",
    "body-parser": "^1.18.2",
    "bootstrap": "^4.1.0",
    "core-js": "^2.4.1",
    "elasticsearch": "^15.1.1",
    "elasticsearch-browser": "^15.1.1",
    "express": "^4.16.3",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "ng2-pdf-viewer": "^5.1.1",
    "npm": "^6.0.1",
    "popper.js": "^1.14.3",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "underscore": "^1.8.3",
    "zone.js": "^0.8.26"
    }

Please help me to fix this issue.

like image 530
MPPNBD Avatar asked Oct 16 '22 15:10

MPPNBD


2 Answers

Try by placing this in your package.json file:

"browser": {    
"zlib":false  }
like image 85
Manuel Roldan Avatar answered Oct 21 '22 09:10

Manuel Roldan


There was a fix for this issue in the following PR https://github.com/mozilla/pdf.js/pull/9924 (merged 12 days ago). You may want upgrading to the latest "pdfjs-dist" to fix the issue.

like image 34
Denys Vuika Avatar answered Oct 21 '22 09:10

Denys Vuika