我正在尝试开始使用Angular教程。 https://angular.io/tutorial/toh-pt6
当我按照说明导入HttpClientModule时,我收到以下错误。
请帮忙。我在mac上使用npm。
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
答案 0 :(得分:2)
您还应该通过添加:
来更改systemjs配置 map: {
...
'@angular/common/http': 'npm:@angular/common/bundles/common-http.umd.js',
'tslib': 'npm:tslib/tslib.js'
另见