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

前端 未结 13 993
我在风中等你
我在风中等你 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:41

    For those of you looking at the older articles, try this solution by re-running the application with ng serve.

    ng generate service InMemoryData --module=app was a previous solution; however, you get this error:

    Unknown option: '--module'

    By default, Angular sets the providedIn property inside of the @Injectable decorator. This takes care of registering the service and hence the --module isn't really a practical solution anymore.

    In order to restart the angular application, you can run in the CLI... taskkill /IM "node.exe" /F

    then, ng serve

提交回复
热议问题