Angular2 Tutorial (Tour of Heroes): Cannot find module 'angular2-in-memory-web-api'

前端 未结 29 2254
青春惊慌失措
青春惊慌失措 2020-11-29 06:25

I have followed the Tutorial. After changing app/maint.ts in the Http chapter I get the error when starting the app via command line:

ap

29条回答
  •  眼角桃花
    2020-11-29 06:52

    I got this error because I was importing InMemoryWebApiModule from angular2-in-memory-web-api I removed the 2. Actually I had two entries in my package.json file; one was angular2-in-memory-web-api and the second wasangular-in-memory-web-api. Using angular-in-memory-web-api solved the problem for me. So your import should be like this:

    import { InMemoryWebApiModule } from 'angular-in-memory-web-api';
    ...
    @NgModule({
    
    imports: [
    InMemoryWebApiModule.forRoot(InMemoryDataService)
    ]
    })
    

    Using cli-angular you need not to change anything regarding system.config.js.

提交回复
热议问题