@auth0/angular-jwt无ɵɵInjectableDeclaration导出成员问题求助
问题:执行npm start时触发@auth0/angular-jwt类型错误
错误详情
执行npm start时出现以下编译错误:
node_modules/@auth0/angular-jwt/lib/jwthelper.service.d.ts has no exported member 'ɵɵInjectableDeclaration'
环境信息
- Angular CLI版本:11.2.19
- Node版本:14.18.1
- 已尝试操作:更换Angular和Node版本,问题未解决
package.json依赖配置
{ "@angular-builders/custom-webpack": "^13.1.0", "@angular/animations": "^11.2.5", "@angular/cdk": "^11.2.4", "@angular/common": "^11.2.5", "@angular/compiler": "^11.2.5", "@angular/core": "^11.2.5", "@angular/fire": "^6.1.4", "@angular/forms": "^11.2.5", "@angular/localize": "^11.2.5", "@angular/material": "^11.2.13", "@angular/platform-browser": "^11.2.5", "@angular/platform-browser-dynamic": "^11.2.5", "@angular/router": "^11.2.5", "@auth0/angular-jwt": "^5.1.2", "@coreui/angular": "^2.11.2", "@coreui/coreui": "^2.1.16", "@coreui/coreui-plugin-chartjs-custom-tooltips": "^1.3.1", "@coreui/icons": "^2.0.0-rc.0", "@coreui/icons-angular": "1.0.0-alpha.3", "@ng-bootstrap/ng-bootstrap": "^10.0.0", "@ngx-translate/core": "^13.0.0", "@ngx-translate/http-loader": "^6.0.0", "@truffle/hdwallet-provider": "^2.0.6", "@types/quill": "^1.3.10", "abi-decoder": "^2.4.0", "alpinejs": "^2.8.2", "angular2-multiselect-dropdown": "^5.0.4", "angularx-qrcode": "^11.0.0", "angularx-social-login": "^3.5.7", "aos": "^2.3.4", "assert": "^2.0.0", "bootstrap": "^4.6.0", "chart.js": "^2.9.4", "classlist.js": "^1.1.20150312", "core-js": "^3.9.1", "crypto-browserify": "^3.12.0", "ethers": "^5.6.2", "file-saver": "^2.0.5", "firebase": "^8.0", "flag-icon-css": "^3.5.0", "font-awesome": "^4.7.0", "fontawesome-4.7": "^4.7.0", "ganache": "^7.0.4", "https-browserify": "^1.0.0", "jquery": "^3.6.0", "lazysizes": "^5.3.2", "micromodal": "^0.4.6", "ng-multiselect-dropdown": "^0.3.4", "ng2-charts": "^2.4.2", "ngx-bootstrap": "^6.2.0", "ngx-captcha": "^10.0.0", "ngx-device-detector": "^2.1.1", "ngx-pagination": "^5.1.1", "ngx-perfect-scrollbar": "^10.1.1", "ngx-quill": "^14.3.0", "os-browserify": "^0.3.0", "quill": "^1.3.7", "quill-blot-formatter": "^1.0.5", "quill-emoji": "^0.2.0", "quill-image-resize-module": "^3.0.0", "rxjs": "^6.6.6", "save": "^2.4.0", "simple-line-icons": "^2.5.5", "slick-carousel": "^1.8.1", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", "swiper": "^8.0.7", "truffle-contract": "^4.0.31", "truffle-hdwallet-provider": "^1.0.17", "ts-helpers": "^1.1.2", "tslib": "^2.0.0", "underscore": "^1.13.1", "uninstall": "0.0.0", "uuid": "^8.3.2", "web-animations-js": "^2.3.2", "web3": "^1.7.1", "xlsx": "^0.16.9", "zone.js": "~0.10.3" }
错误截图

解决方案
问题核心是**@auth0/angular-jwt版本与Angular版本不兼容**:
当前使用的@auth0/angular-jwt@5.1.2是为Angular 12+开发的,而你的Angular 11.x核心库中不存在ɵɵInjectableDeclaration这个导出成员(该类型是Angular 12+新增的)。
修复步骤:
- 卸载当前版本的@auth0/angular-jwt:
npm uninstall @auth0/angular-jwt
- 安装与Angular 11兼容的4.x版本(推荐4.2.0):
npm install @auth0/angular-jwt@4.2.0 --save
- 重新执行
npm start即可解决问题。
如果仍有异常,可尝试清除缓存并重装依赖:
npm cache clean --force rm -rf node_modules package-lock.json npm install npm start
内容的提问来源于stack exchange,提问作者Von031300
相关产品推荐
相关产品推荐

