I m using ng2-pdf-viewer in angular 6 project,
On project compilation it gives following errors
ERROR in node_modules/@types/pdfjs-dist/index.d.ts(63,39): error TS2304: Cannot find name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(65,34): error TS2304: Cannot find name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(80,31): error TS2304: Cannot find name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(82,30): error TS2304: Cannot find name 'unknown'
my package.json file is as post below
"dependencies": {
"@angular/animations": "^6.1.10",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@vimeo/player": "^2.10.0",
"@types/node": "10.3.1",
"angular-6-datatable": "~0.8.0",
"angular-6-social-login": "~1.1.1",
"bootstrap": "^4.3.1",
"core-js": "^2.5.4",
"crypto-js": "~3.1.9-1",
"devextreme": "^19.1.5",
"devextreme-angular": "^19.1.5",
"font-awesome": "~4.7.0",
"jquery": "^3.4.1",
"ng2-drag-drop": "^3.0.2",
"ng2-pdf-viewer": "^6.0.2",
"ng5-slider": "^1.2.4",
"ngx-bootstrap": "^3.3.0",
"ngx-drag-scroll": "~7.4.2",
"ngx-image-cropper": "~1.3.10",
"ngx-loading": "^3.0.1",
"ngx-owl-carousel-o": "~1.1.5",
"ngx-rating": "0.0.9",
"ngx-slick-carousel": "^0.4.4",
"ngx-toastr": "~10.0.4",
"ngx-ui-loader": "^7.2.2",
"popper.js": "~1.15.0",
"rxjs": "~6.2.0",
"rxjs-compat": "^6.5.2",
"slick-carousel": "^1.8.1",
"stream": "0.0.2",
"swiper": "^4.5.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.8.0",
"@angular/cli": "~6.2.9",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "~4.3.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~2.9.2"
}
This is my package.json file
I had a similar problem with my project based on Angular 6. From package.json:
"dependencies": {
...
"ng2-pdf-viewer": "^5.2.3",
"rxjs": "6.3.3",
},
"devDependencies": {
...
"typescript": "^2.7.2"
}
From package-lock.json (1st generated by npm install command):
...
"ng2-pdf-viewer": {
"version": "5.3.4",
"resolved": "_removed_",
"integrity": "_removed_",
"requires": {
"@types/pdfjs-dist": "^2.0.1",
"pdfjs-dist": "^2.2.228",
"tslib": "^1.9.0"
}
},
...
"pdfjs-dist": {
"version": "2.2.228",
"resolved": "_removed_",
"integrity": "_removed_",
"requires": {
"node-ensure": "^0.0.0",
"worker-loader": "^2.0.0"
}
},
...
"@types/pdfjs-dist": {
"version": "2.1.3",
"resolved": "_removed_",
"integrity": "_removed_"
},
...
In order to solve the problem, I change @types/pdfjs-dist version to "2.1.0" in the package-lock.json file. Delete the node_modules folder, then execute "npm install".
Another problem you may encounter is
ERROR in node_modules/@types/pdfjs-dist/index.d.ts(7,1): error TS1084: Invalid 'reference' directive syntax.
To solve this problem, open the file "node_modules/@types/pdfjs-dist/index.d.ts", then search for three slashes near line 7
/// <reference lib="dom"/>
then remove a slash to "
// <reference lib="dom"/>