Shamal Karunarathne
Shamal Karunarathne

Reputation: 1849

Angular Tour of Heroes Error Importing HttpClientModule

I'm trying the getting started on Angular tutorial. https://angular.io/tutorial/toh-pt6

When I import the HttpClientModule as per the instructions, I get the error below.

Please help. I'm using npm on mac.

Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/node_modules/@angular/common/bundles/common.umd.js/http
Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/@angular/common/bundles/common.umd.js/http
    at XMLHttpRequest.wrapFn (http://localhost:3000/node_modules/zone.js/dist/zone.js:1166:39)
    at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:425:31)
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:192:47)
    at ZoneTask.invokeTask [as invoke] (http://localhost:3000/node_modules/zone.js/dist/zone.js:499:34)
    at invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:1540:14)
    at XMLHttpRequest.globalZoneAwareCallback (http://localhost:3000/node_modules/zone.js/dist/zone.js:1566:17)
Error loading http://localhost:3000/node_modules/@angular/common/bundles/common.umd.js/http as "@angular/common/http" from http://localhost:3000/app/app.module.js
    at XMLHttpRequest.wrapFn (http://localhost:3000/node_modules/zone.js/dist/zone.js:1166:39)
    at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:425:31)
    at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:192:47)
    at ZoneTask.invokeTask [as invoke] (http://localhost:3000/node_modules/zone.js/dist/zone.js:499:34)
    at invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:1540:14)
    at XMLHttpRequest.globalZoneAwareCallback (http://localhost:3000/node_modules/zone.js/dist/zone.js:1566:17)
Error loading http://localhost:3000/node_modules/@angular/common/bundles/common.umd.js/http as "@angular/common/http" from http://localhost:3000/app/app.module.js

Upvotes: 2

Views: 729

Answers (1)

yurzui
yurzui

Reputation: 214017

You should also change your systemjs config by adding:

 map: {
  ...
  '@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
  'tslib': 'npm:tslib/tslib.js'

enter image description here

See also

Upvotes: 2

Related Questions