Need to fix error not found in module - Angular

Vince

I'm practicing angular, but received this error while compiling my code:

Module not found: Error: Can't resolve './app.component.css' in 'D:\hello-world-app\src\app'
i 「wdm」: Failed to compile.

My app.component.html

<h1>Angular</h1>
<courses></courses>

My courses.component.ts

// tslint:disable-next-line: import-spacing
import{Component} from '@angular/core';


@Component({
  selector: 'courses', //<courses>
  template: '<h2>Courses</h2>'
})
export class CoursesComponent {

}

My app.component.ts


import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'hello-world-app';
}

My app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { CoursesComponent } from './courses.component';

@NgModule({
  declarations: [
    AppComponent,
    CoursesComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Jacques ジャック

Angular is failing to find (resolve) the file, just as the error states. In order to fix the error, you need to either add the file, or delete the line styleUrls: ['./app.component.css']

If you do not want to avoid the file reference and are using angular cli (if you're not, you probably should be), you can use --inlineStyle=true when generating a component. Granted, if you're using angular cli, the css file should have been created when the component was generated.

Odds are either you copy pasted some stuff, or mistakenly deleted that file. Either way, Angular will always complain when it can't find something you're referencing. (Much like pretty much every other programming framework/system/language)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fix "Module not found: Error: Can't resolve *" error

Angular 4: Module not found error regarding RxJs

Angular 6: Module not found error regarding RxJs

How to fix missing 'module not found' build error in Ionic 3 application

How to fix Next.js Vercel deployment module not found error

Angular 2 - Module not found: Error: Can't resolve '@angular/material'

Error: Module not found: Error: Can't resolve '@angular/cdk/scrolling'

Angular 8 - Module not found: Error: Can't resolve 'fs' in

Module not found: Error: Can't resolve '@angular/core'

Angular 6 setTimeout Module not found: Error: Can't resolve 'timers'

Module not found: Error: Can't resolve '@angular/animations'

Angular 2: Module not found: Error: Can't resolve

Angular: Getting a module not found error only when building for prod

Angular 8 Animations Error on Lazy Loaded Module - Found Synthetic Property

Angular 6 - Module not found: Error: Can't resolve 'http' in

Module not found error with vis-timeline and angular 8

Module not found Error : Can't resolve './ ' in Angular8

Injecting a module into angular as module not found

Angular - Module not found

Module not found in angular 2

Angular module not found

Gulp error (module not found)

module error not found on react

Module not found: Error can't resolve 'child_process', how to fix?

How to fix this error : " Module not found :can't resolve popper.js "

How to fix material-kit-react 'module not found: webpack loader error'

How to fix "SQLite Error 1: 'The specified module could not be found." with EF and Spatialite

How to fix import error "Module not found: Can't resolve './components'" - using Named Exports

Need to fix simple layout error