Hi I have a problem with angular-in-memory-web-api. I tried to use angular2-in-memory-web-api in SystemJS and another solutions her but with no result. I\'m using official quick
Even after I tried everything mentioned before I still got this error:
"originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading node_modules/angular-in-memory-web-api/bundles/in-memory-web-api.umd.js\n\tError: XHR error (404 Not Found) loading node_modules/angular-in-memory-web-api/bundles/in-memory-web-api.umd.js\n\t at XMLHttpRequest.wrapFn [as _onreadystatechange] (node_modules/zone.js/dist/zone.js:889:29) [
Then I realized, that it only occurs during tests with karma (no ... I do not try start the server if tests fail).
This worked for me:
systemjs.config.js as described by others here (and meanwhile fixed in original sample code): 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
karma.conf.js:
files: [
(...)
'node_modules/angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
(...)
{ pattern: 'node_modules/angular-in-memory-web-api/**/*.js', included: false, watched: false },
]
additional I had to set a provider for { provide: APP_BASE_HREF, useValue: "/" }
because karma doesn't use the index.html
finally all tests passed and I can do my "npm start" :-)