Cant find Module error in Angular when following the steps from angular.io

Viewed 1209

This is my first Angular App which I am building from angular.io documentation. I have followed the same steps as they have mentioned and I see that when I generate new components they are not getting added to app.module so I tried added them and here I am getting the following error

Cannot find module './product-alerts/product-alerts.component'.

This app is being built in stackblitz so please find the links for my project.

EditorURl: https://stackblitz.com/edit/angular-tejatest1

3 Answers

A similar issue was seen following the exact steps and the solution was IT-Crowd-like: saving the project and reloading the page!

It's because your product-alerts component is outside of app folder. Change your import in module like this: Or move your product-alerts inside app folder.

Try this:

app.module.ts

import { ProductAlertsComponent } from '../product-alerts/product-alerts.component';

Sometimes this also happens when a component in Stackblitz is created, then deleted. The Imports happens to not get deleted automatically. This can lead to confusing situations.

Related