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.
Hafsa Ben amara is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1