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

前端 未结 29 2168
青春惊慌失措
青春惊慌失措 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:59

    I create my project using angular-cli and i set in package.json "angular-in-memory-web-api": "^0.2.4" in dependences block and then i run npm install.

    Work for me :D

    0 讨论(0)
  • 2020-11-29 07:00
    import { InMemoryBackendService, SEED_DATA } from 'angular2-in-memory-web-api';
    import { InMemoryDataService }               from './in-memory-data.service';
    

    The InMemoryDataService class doesn't come under any API. We need to create a service class and then import that service class into app.module.ts file.

    0 讨论(0)
  • 2020-11-29 07:01

    I am using angular 4 and below solved my problem.

    npm install angular-in-memory-web-api --save

    0 讨论(0)
  • 2020-11-29 07:01

    This was a real stinker. Thanks to @traneHead, @toni and others, these steps worked for me.

    1. Upgrade angular2-in-memory-web-api to 0.0.10
    2. Edit the packages variable property in systemjs.config.js:

    angular2-in-memory-web-api': { main: 'core.js', defaultExtension: 'js' }

    0 讨论(0)
  • 2020-11-29 07:01

    I had the same problem, I changed in systemjs.config :

    'angular2-in-memory-web-api': { defaultExtension: 'js' },
    

    By this line :

    'angular2-in-memory-web-api': { main: 'core.js', defaultExtension: 'js' },
    
    0 讨论(0)
  • 2020-11-29 07:01

    I solved it copying index.js and index.d.ts to core.js and core.d.ts, that is, inside node_modules/angular2-in-memory-web-api folder. Go figure out.

    0 讨论(0)
提交回复
热议问题