Cannot GET / error in angular 6 .net core 2.1

Viewed 10712

I want to show toast notification in my angular form. I am using visual studio .net core 2.1 template...I am getting

Cannot GET / error when running localhost...

running ng build following errors shown...

../../../../../node_modules/ng2-toasty/index.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/shared.d.ts(1,30): error TS2307: Cannot find module '@angular/platform-browser'. ../../../../../node_modules/ng2-toasty/src/shared.d.ts(2,31): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toast.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toasty.component.d.ts(1,24): error TS2307: Cannot find module '@angular/core'. ../../../../../node_modules/ng2-toasty/src/toasty.service.d.ts(1,28): error TS2307: Cannot find module 'rxjs/Observable'.

AppModule:

import { VehicleFormComponent } from './vehicle-form/vehicle-form.component';
import { VehicleService } from './services/vehicle.service';
import { ToastyModule } from 'ng2-toasty';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { RouterModule } from '@angular/router';

@NgModule({
  declarations: [
    AppComponent,
    NavMenuComponent,
    HomeComponent,
    VehicleFormComponent
  ],
  imports: [
    BrowserModule.withServerTransition({
      appId: 'ng-cli-universal'
    }),
    FormsModule,
    HttpClientModule,
    FormsModule,
    ToastyModule.forRoot(),
    RouterModule.forRoot([
      {
        path: '',
        component: HomeComponent,
        pathMatch: 'full'
      },
      {
        path: 'vehicles/new',
        component: VehicleFormComponent
      }
    ])
  ],
  providers: [VehicleService],
  bootstrap: [AppComponent]
})
export class AppModule {}
4 Answers

This is basically due to any sort of compilation error occurs on building the angular application. Make sure that the npm console is clean. To do this, just run the command npm start from VSCode npm console.

This will be basically an error in your Angular application. You can check "Output" window in Visual studio, which displays the exact error message.Here is the sample error you can find in Output window

I solved this with ngx-toastr library what you need to do is to update your angular application to latest version(from ClienApp folder). Use this Link.

After you do update add ngx-toastr like they explain on the website and you will be able to run the application.
Or you can just install older version of ngx-toasty with this command and it will work.

npm install ngx-toastr@8.10.2 --save

I was facing the same problem.You need to do a little change in app.module.ts file mostly available in (..\ClientApp\src\app\app.module.ts).Just remove the deleted components and declarations from app.module.ts

Related