11

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 {}
3
  • what is the version of angular are you using?. the package supports systemjs. IF you are using Angular 4+ please use npmjs.com/package/angular2-toaster Commented Aug 31, 2018 at 17:12
  • 2
    @Saeef ahmed Have you seen the error details? Commented Aug 31, 2018 at 17:30
  • yes..added in my question Commented Aug 31, 2018 at 17:35

4 Answers 4

6

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.

Sign up to request clarification or add additional context in comments.

Comments

4

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

Comments

1

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.