小编Sal*_*yed的帖子

使用模块联合架构导入角度应用程序时,“必须从注入上下文调用inject()”

我正在尝试按照此示例使用webpack5 模块联合来实现 Angular 中的微前端概念Module federation with Angular,但我面临这个错误错误:未捕获(承诺中):错误:必须从注入上下文调用inject()

我尝试了这个答案中提供的解决方案,必须从注入上下文调用inject(),但它不起作用。

目前我在这两个应用程序中都使用 Angular 版本 11。

正在导入的应用程序的 package.json (子级)

    "resolutions": {
    "webpack": "5.0.0"
  },
  "dependencies": {
    "@angular/animations": "11.0.0-next.6",
    "@angular/cdk": "11.0.0-next.6",
    "@angular/common": "11.0.0-next.6",
    "@angular/compiler": "11.0.0-next.6",
    "@angular/core": "11.0.0-next.6",
    "@angular/forms": "11.0.0-next.6",
    "@angular/platform-browser": "11.0.0-next.6",
    "@angular/platform-browser-dynamic": "11.0.0-next.6",
    "@angular/platform-server": "^11.0.0",
    "@angular/router": "11.0.0-next.6",
    "@angular/service-worker": "11.0.0-next.6",
    "@fortawesome/angular-fontawesome": "^0.8.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.32",
    "@fortawesome/free-solid-svg-icons": "^5.15.1",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "angular-font-awesome": "^3.1.2",
    "bootstrap": "^4.3.1",
    "classlist.js": "^1.1.20150312",
    "core-js": "^3.1.4",
    "file-saver": "^2.0.2",
    "font-awesome": "^4.7.0",
    "js2xmlparser": "^4.0.0",
    "moment": "^2.25.3",
    "moment-timezone": "^0.5.28",
    "ngx-webstorage-service": "^4.1.0",
    "node-sass": …
Run Code Online (Sandbox Code Playgroud)

angular micro-frontend webpack-5 angular11 webpack-module-federation

5
推荐指数
1
解决办法
4265
查看次数