gpt4 book ai didi

angular - node_modules/@auth0/angular-jwt/lib/jwtoptions.token.d.ts(2,50) : error TS2304: Cannot find name 'unknown' 中的错误

转载 作者:行者123 更新时间:2023-12-04 15:20:37 30 4
gpt4 key购买 nike

编译我的 Angular 项目时,出现以下错误。我删除了我的 node_modules 文件并重新安装它仍然没有用。

node_modules/@auth0/angular-jwt/lib/jwtoptions.token.d.ts(2,50) 中的错误:错误 TS2304:找不到名称“未知”。

enter image description here

包.json

{
"name": "ArinhureWeb",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run ArinhureWeb:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "6.1.10",
"@angular/common": "6.1.10",
"@angular/compiler": "6.1.10",
"@angular/core": "6.1.10",
"@angular/forms": "6.1.10",
"@angular/http": "6.1.10",
"@angular/platform-browser": "6.1.10",
"@angular/platform-browser-dynamic": "6.1.10",
"@angular/platform-server": "6.1.10",
"@angular/router": "6.1.10",
"@auth0/angular-jwt": "^5.0.1",
"@nguniversal/module-map-ngfactory-loader": "6.0.0",
"aspnet-prerendering": "^3.0.1",
"bootstrap": "^4.1.3",
"chart.js": "^2.9.3",
"core-js": "^2.5.4",
"jquery": "3.3.1",
"popper.js": "^1.14.3",
"rxjs": "6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.0",
"@angular/cli": "~6.0.0",
"@angular/compiler-cli": "6.1.10",
"@angular/language-service": "^6.0.0",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"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": "~1.4.2",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"typescript": "~2.7.2"
},
"optionalDependencies": {
"node-sass": "^4.9.3",
"protractor": "~5.4.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1"
}
}

最佳答案

我遇到了这个问题并找到了解决方案。查看 documentation 后,我目前正在运行 Angular 6 并安装了 4.2 版上面写着“对于 Angular v6+ 到 v9,使用 @auth0/angular-jwt v4”。我得到了同样的错误:

fail: Microsoft.AspNetCore.SpaServices[0]node_modules/@auth0/angular-jwt/lib/jwtoptions.token.d.ts(2,50): error TS2304: Cannot find name 'unknown'.

我在 node_modules 中打开了 jwtoptions.token.d.ts 文件,它是一个简单的两行文件:

import { InjectionToken } from '@angular/core';
export declare const JWT_OPTIONS: InjectionToken<unknown>;

'unknown' 是 typescript 3 中引入的新类型,Angular 6.0.9 依赖于 typescript ~2.7。此外,@auth0/angular-jwt 依赖项的 4.2 版本以 Angular 7.1+ 为目标,您可以从这个 npm 警告中看到:

npm WARN @auth0/angular-jwt@4.2.0 requires a peer of @angular/common@>=7.1.0 but none is installed. You must install peer dependencies yourself.

我认为这个包在支持旧版 Angular 时遇到了问题。我简单的降级到了@auth0/angular-jwt@3.0.1这个版本就没有报错了。

这是我的 package.json:

  "dependencies": {
"@angular/animations": "6.0.9",
"@angular/cdk": "^6.4.7",
"@angular/common": "6.0.9",
"@angular/compiler": "6.0.9",
"@angular/core": "6.0.9",
"@angular/forms": "6.0.9",
"@angular/http": "6.0.9",
"@angular/material": "^6.4.7",
"@angular/platform-browser": "6.0.9",
"@angular/platform-browser-dynamic": "6.0.9",
"@angular/router": "6.0.9",
"@auth0/angular-jwt": "3.0.1",
"@ng-idle/core": "^6.0.0-beta.3",
"@ng-idle/keepalive": "^6.0.0-beta.3",
"angular2-moment": "^1.9.0",
"bootstrap": "3.3.2",
"bootstrap-tree": "1.2.0",
"chart.js": "2.0.2",
"core-js": "2.4.1",
"font-awesome": "4.7.0",
"formvalidation": "0.6.2-dev",
"jquery": "1.11.2",
"jquery-match-height": "0.7.2",
"jquery-sparkline": "2.3.2",
"jstree": "3.3.4",
"ngx-bootstrap": "3.0.1",
"noty": "2.4.1",
"pdfmake-client": "1.0.0",
"primeicons": "1.0.0-beta.9",
"primeng": "6.0.0",
"rxjs": "6.0.0",
"rxjs-compat": "6.2.2",
"sortablejs": "1.6.0",
"webpack": "^4.4.0",
"zone.js": "0.8.26"
},
"devDependencies": {
"@angular/cli": "6.1.4",
"@angular/compiler-cli": "6.0.9",
"@angular/language-service": "6.0.9",
"@angular-devkit/build-angular": "0.6.7",
"@angular-devkit/core": "0.5.11",
"@types/jasmine": "2.8.3",
"@types/jasminewd2": "2.0.2",
"@types/node": "6.0.60",
"codelyzer": "4.0.1",
"jasmine-core": "2.8.0",
"jasmine-spec-reporter": "4.2.1",
"karma": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.2.1",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"protractor": "5.1.2",
"ts-node": "3.2.0",
"tslint": "5.9.1",
"typescript": "2.7.2"
},

关于angular - node_modules/@auth0/angular-jwt/lib/jwtoptions.token.d.ts(2,50) : error TS2304: Cannot find name 'unknown' 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63400257/

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