gpt4 book ai didi

angular - node_modules/@types/pdfjs-dist/index.d.ts(63,39) : error TS2304: Cannot find name 'unknown' 中的错误

转载 作者:行者123 更新时间:2023-12-05 09:11:51 28 4
gpt4 key购买 nike

我在 Angular 6 项目中使用 ng2-pdf-viewer,

项目编译时出现如下错误

ERROR in node_modules/@types/pdfjs-dist/index.d.ts(63,39): errorTS2304: Cannot find name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(65,34): error TS2304: Cannotfind name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(80,31): error TS2304: Cannotfind name 'unknown'.
node_modules/@types/pdfjs-dist/index.d.ts(82,30): error TS2304: Cannotfind name 'unknown'

我的 package.json 文件如下所示

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

这是我的 package.json 文件

最佳答案

我在基于 Angular 6 的项目中遇到了类似的问题。来自 package.json:

  "dependencies": {
...
"ng2-pdf-viewer": "^5.2.3",
"rxjs": "6.3.3",
},
"devDependencies": {
...
"typescript": "^2.7.2"
}

来自 package-lock.json(第一个由 npm install 命令生成):

...
"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_"
},
...

为了解决问题,我将package-lock.json文件中的@types/pdfjs-dist版本改为“2.1.0”。删除 node_modules 文件夹,然后执行“npm install”。

你可能遇到的另一个问题是

ERROR in node_modules/@types/pdfjs-dist/index.d.ts(7,1): error TS1084: Invalid 'reference' directive syntax.

要解决此问题,请打开文件“node_modules/@types/pdfjs-dist/index.d.ts”,然后在第 7 行附近搜索三个斜杠

/// <reference lib="dom"/>

然后删除一个斜线到“

// <reference lib="dom"/>

关于angular - node_modules/@types/pdfjs-dist/index.d.ts(63,39) : error TS2304: Cannot find name 'unknown' 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59624698/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com