Reputation: 11
I’ve been migrating my Angular app to use standalone components following the official migration guide. I ran the following commands:
ng g @angular/core:standalone and selected "Convert all components, directives, and pipes to standalone" ng g @angular/core:standalone and selected "Remove unnecessary NgModule classes" ng g @angular/core:standalone and selected "Bootstrap the project using standalone APIs" However, after completing the third step, when I run the application with ng serve --ssl, I encounter the following error in the browser console:
Uncaught RuntimeError: NG0800: Importing providers supports NgModule or ModuleWithProviders but got a standalone component "XYZComponent"
What I tried:
I’ve ensured that all components are correctly marked as standalone, with the standalone: true flag in the @Component decorator. All services are injected directly into the standalone components as providers in the @Component decorator. The application was previously using @NgModule, and now I’ve removed the NgModules, as instructed by the migration steps.
Upvotes: 1
Views: 121
Reputation: 4183
I got this too. In my case it meant I was still using providers to import XYZComponent. I deleted that provider reference completely: it was no longer necessary.
Upvotes: 0