Why Am I Getting Angular Error NG8001 Not A Known Element?

Discussão em 'Angular' iniciado por Brad Richerson, Março 17, 2025.

  1. I'm trying to figure out why I keep getting this error message when running ng serve. I'm new to Angular so I'm not sure where the problem is happening, but I will lay out what I did so maybe that helps to find a solution.

    1. `ng new project-name
    2. `ng generate component component-name
    3. Insert component selector into root component html file
    4. ng serve
    5. Error NG8001

    The only answer I keep finding is that the new component has to be imported into the root component's imports, but when I generated the component in the CLI it is automatically imported and added to the imports. I got the error to go away by deleting and re-entering the import statement and imports array, but I'm curious as to why this error is happening when the CLI ng g c component-name is already doing that to begin with.

    I'm using Angular 17 and standalone components

    Continue reading...

Compartilhe esta Página