【问题标题】:Undefined import error Angular 2 with JsonpModule带有 JsonpModule 的未定义导入错误 Angular 2
【发布时间】:2018-01-08 01:06:30
【问题描述】:

我的 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 {}

当我添加 import {JsonpModule} from '@angular/http';

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

(index):25 错误:(SystemJS) 模块“AppModule”导入的意外值“未定义” 错误:模块“AppModule”导入的意外值“未定义” 在评估 (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) 在 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) 在评估 (http://localhost:3000/app/main.js:7:4) 评估http://localhost:3000/app/main.js 加载时出错http://localhost:3000/app/main.js 在评估 (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) 在 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) 在评估 (http://localhost:3000/app/main.js:7:4) 评估http://localhost:3000/app/main.js 加载时出错http://localhost:3000/app/main.js

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

【问题讨论】:

    标签: angular


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2017-05-20
      • 2017-11-01
      • 1970-01-01
      • 2020-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-16
      相关资源
      最近更新 更多