Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot GET / error in angular 6 .net core 2.1

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 {}
like image 943
saeef ahmed Avatar asked Aug 31 '18 17:08

saeef ahmed


3 Answers

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

like image 195
Sachin jeev Avatar answered Sep 30 '22 04:09

Sachin jeev


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.

like image 25
Anvid Avatar answered Sep 30 '22 04:09

Anvid


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 [email protected] --save
like image 41
haris369 Avatar answered Sep 30 '22 06:09

haris369