-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nx angular dynamic mfe got NG0203 error #27162
Comments
I am also getting same error "Error: NG0203: inject() must be called from an injection context such as a constructor". Nx Report: Node : 20.14.0 nx (global) : 19.5.6 |
Im also seeing the same issue on the latest v19.6.0. I had to downgrade to v19.4.4 for dynamic federation to work. I have notice by default that when we upgrade to >=v19.5.0, it automatically uses the new module/federation-enhance. Is there something we need to do in our module federation config to adhere to the new mf-enchance version ?
|
…#27162 (#27513) <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> The host application is never set as a candidate to share packages from. Particularly in angular, this causes issues with the injection context ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Host application should be a valid option for sharing packages ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #27162 (cherry picked from commit 8137708)
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
I had no issuse since i used nx mfe with angular 15,
but i tried to migrate to angular 18 and got this error when navigating from shell (host) app to another mfe
Error: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with runInInjectionContext. Find more at https://angular.dev/errors/NG0203
i also saw this topic
#19121
and then i tried it on my two envirements which is a windows system and debian linux, and in both cases got the same error.
Expected Behavior
Navigating between mfes without any issue
GitHub Repo
https://github.com/mehrabix/nx-angular-mfe
Steps to Reproduce
clone this repo
https://github.com/mehrabix/nx-angular-mfe
do npm i
run this command:
npx nx serve shell --devRemotes="first-microfront,second-microfront"
Navigate between mfes
you will get NG0203 error on console
another clue:
Clone this repository (it's mentioned in the Angular MFE tutorial: https://nx.dev/recipes/angular/dynamic-module-federation-with-angular):
https://github.com/Coly010/nx-ng-dyn-fed
Run:
npx nx serve employee --devRemotes="dashboard,todo,login"
navigate between remote links
The Angular version is 18.0.4, and it works perfectly.
Then, run this in order to migrate to Angular 18.1.2. It will migrate successfully:
nx migrate latest
After that, run:
npx nx serve employee --devRemotes="dashboard,todo,login"
again.
navigate between remote links
It will not work anymore, and you will get the NG0203 error.
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: