Cannot find module './in-memory-data-service' in tour of heroes for Angular2

前端 未结 13 971
我在风中等你
我在风中等你 2021-02-06 21:49

I am trying to work through the Angular2 tour of heroes app, and am running into bugs on the Http section of the tutorial.

At first I was getting the error:

         


        
13条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 22:44

    To resolve this issue I did

    ng generate service InMemoryData --module=app  
    

    as suggested by user user875234

    But also a lot of answers here have copied and pasted from the question

    import { InMemoryDataService } from './in-memory-data-service';  
    

    Which is wrong. It should be as it appears in the Heroes tutorial

    import { InMemoryDataService } from './in-memory-data.service';  
    

    Notice the "dataDOTservice", not a hyphen. It looks to us newbies like a mistake in the tutorial, and it doesn't match OP's question or some answers here. The dot is correct, the hyphen is wrong.

提交回复
热议问题