未定义的导入错误Angular 2 with JsonpModule

时间:2017-08-01 08:51:06

标签: angular

我的app.module.ts文件中有以下代码

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {JsonpModule} from '@angular/http';

import {AppComponent} from './app.component';
import {WeatherComponent} from './weather-
 widget/component/weather.component';

@NgModule({
    imports: [BrowserModule, JsonpModule],
    declarations: [AppComponent, WeatherComponent],
    bootstrap: [AppComponent]
})

export class AppModule {}

当我从' @ angular / http&#39 ;;

添加 import {JsonpModule}时

我收到以下错误(没有导入一切都很好):

  

(index):25错误:(SystemJS)意外的值' undefined'由模块导入的AppModule'       错误:意外的值' undefined'由模块导入的AppModule'           在eval(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14331:33)           在Array.forEach()           在CompileMetadataResolver.getNgModuleMetadata(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14311:46)           在RuntimeCompiler._compileComponents(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:17063:49)           at RuntimeCompiler._compileModuleAndComponents(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:17001:39)           在RuntimeCompiler.compileModuleAsync(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:23)           在PlatformRef _._ bootstrapModuleWithZone(http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:6684:29)           在PlatformRef_.bootstrapModule(http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:6666:25)           在Object.eval(http://localhost:3000/app/main.js:5:10)           在eval(http://localhost:3000/app/main.js:7:4)       评估http://localhost:3000/app/main.js       加载http://localhost:3000/app/main.js时出错           在eval(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14331:33)           在Array.forEach()           在CompileMetadataResolver.getNgModuleMetadata(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:14311:46)           在RuntimeCompiler._compileComponents(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:17063:49)           at RuntimeCompiler._compileModuleAndComponents(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:17001:39)           在RuntimeCompiler.compileModuleAsync(http://localhost:3000/node_modules/@angular/compiler/bundles/compiler.umd.js:16992:23)           在PlatformRef _._ bootstrapModuleWithZone(http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:6684:29)           在PlatformRef_.bootstrapModule(http://localhost:3000/node_modules/@angular/core/bundles/core.umd.js:6666:25)           在Object.eval(http://localhost:3000/app/main.js:5:10)           在eval(http://localhost:3000/app/main.js:7:4)       评估http://localhost:3000/app/main.js       加载http://localhost:3000/app/main.js

时出错

我已经阅读了多个可能出现问题的解决方案,但没有取得任何成功。任何建议将不胜感激。

1 个答案:

答案 0 :(得分:0)

我找到了原因。我在systemjs.config.js文件中出错了。 @ angular / http映射在url中有错误。