npm Angular编译警告:“在'@angular/core'中未找到导出'可定义的可注入'”

8fq7wneg  于 11个月前  发布在  Angular
关注(0)|答案(2)|浏览(153)

我试图为一个Angular应用程序提供服务,但我从“ngx-mqtt”:“^6.6.0”中得到此依赖项错误。我的本地CLI是6.2.9版本。我试图更改此依赖项的版本,但我仍然得到此错误。我只是不知道为什么会发生这种情况。
错误in ./node_modules/ngx-mqtt/src/mqtt.service.js 390:34-55“在”@angular/core“中未找到导出"可定义的可注入”(导入为“i 0”)
错误in ./node_modules/ngx-mqtt/src/mqtt.service.js 390:126-137“在”@angular/core“中未找到导出”缓存注入“(导入为”i 0“)
错误in ./node_modules/ngx-mqtt/src/mqtt.service.js 390:161-172“在”@angular/core“中未找到导出”缓存注入“(导入为”i 0“)
这些是我对package.json的主要依赖

"dependencies": {
        "@angular/animations": "^6.1.7",
        "@angular/cdk": "^6.4.7",
        "@angular/cli": "~6.2.1",
        "@angular/common": "^6.1.0",
        "@angular/compiler": "^6.1.0",
        "@angular/compiler-cli": "^6.1.0",
        "@angular/core": "^6.1.0",
        "@angular/flex-layout": "^6.0.0-beta.18",
        "@angular/forms": "^6.1.0",
        "@angular/http": "^6.1.0",
        "@angular/material": "^6.4.7",
        "@angular/material-moment-adapter": "^6.4.7",
        "@angular/platform-browser": "^6.1.0",
        "@angular/platform-browser-dynamic": "^6.1.0",
        "@angular/router": "^6.1.0",
        "@fortawesome/angular-fontawesome": "^0.3.0",
        "@fortawesome/fontawesome-svg-core": "^1.2.21",
        "@fortawesome/free-regular-svg-icons": "^5.10.1",
        "@fortawesome/free-solid-svg-icons": "^5.10.1",
...

个字符

5vf7fwbs

5vf7fwbs1#

"ngx-mqtt": "^6.6.0"中删除字符^解决了问题。

5fjcxozz

5fjcxozz2#

当前项目angular版本Angular CLI:6.1.5 Node:14.17.2
1.删除节点模块文件夹
1.删除package-lock.json
1.编辑程序包

{
  "name": "project",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod -c code-qa",
    "ssl": "ng serve --port 4400 --ssl true --ssl-cert ../ssl/server.crt --ssl-key ../ssl/server.key",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.0.0-beta.7",
    "@amcharts/amcharts4": "^4.10.24",
    "@angular/animations": "^6.1.0",
    "@angular/cdk": "^6.4.7",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/fire": "^5.2.1",
    "@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",
    "@egjs/view360": "^3.2.2-rc",
    "@ng-bootstrap/ng-bootstrap": "^2.1.1",
    "@ng-idle/core": "^8.0.0-beta.4",
    "@ng-idle/keepalive": "^8.0.0-beta.4",
    "@ng-select/ng-select": "^2.1.1",
    "@ngx-share/core": "^7.1.4",
    "angular-progress-bar": "^1.0.9",
    "chart.js": "^2.9.2",
    "core-js": "^2.5.4",
    "find-remove": "^2.0.0",
    "jquery": "^3.4.1",
    "jw-angular-social-buttons": "^1.0.0",
    "marzipano": "^0.9.0",
    "moment": "^2.24.0",
    "ng-intercom": "^8.0.0",
    "ng-recaptcha": "^5.0.0",
    "ng-simple-slideshow": "^1.2.9",
    "ngx-gallery": "^5.10.0",
    "ngx-moment": "^3.5.0",
    "ngx-owl-carousel": "^2.0.7",
    "ngx-owl-carousel-o": "2.0.3",
    "ngx-pagination": "^5.1.1",
    "ngx-rangeslider-component": "^1.0.6",
    "ngx-socket-io": "^3.0.1",
    "ngx-spinner": "^7.2.0",
    "ngx-toastr": "^10.0.4",
    "rxjs": "6.0.0",
    "zone.js": "~0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.7.0",
    "@angular/cli": "~6.1.5",
    "@angular/compiler-cli": "^6.1.10",
    "@angular/language-service": "^6.1.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": "^4.2.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "^2.9.2"
  }
}

字符串
1.保存所有更改的文件后,运行npm i --legacy-peer-deps
5.run npm start
6.如果您收到以下警告
请参阅./node_modules/@agm/core/fesm 5/agm-core.js 4538:120-128“在”@angular/core“中未找到导出”可注入“请参阅./node_modules/@agm/core/fesm 5/agm-core.js 4538:34-52“在”@angular/core“中未找到导出”可注入定义“请参阅./node_modules/@ agm/core/fesm 5/agm-core. js 4538:34-52”编译时出现警告。
1.转到路径./node_modules/@agm/core/fesm 5/agm-core.js,打开agm-core.js文件,搜索“注入”,然后删除“ee”,并将其保留为“注入”搜索“注入defineInjectable”,删除“ee”,并将其保留为“defineInjectable”
8.save此更改的文件
1.再次运行npm start
1.它会工作
感谢大家

相关问题