Nativescript - 错误:找不到'AppModule'的NgModule元数据

时间:2017-11-09 12:32:25

标签: javascript angular nativescript

我正在使用杂货演示应用程序(来自NS)。 - Android。

我必须说,如果我跑:tns run android - 一切OK

当我安装nativescript-dev-webpack时,问题已经开始了 - 如果我运行的话: npm run start-android-bundle,我收到错误:

JS: Timeline: Modules: onActivityResumed com.tns.gen.android.app.Application_ActivityLifecycleCallbacks@46bcb04  (346195420.913214ms. - 346195436.816214ms.)
System.err: java.lang.RuntimeException: Unable to resume activity {org.nativescript.Groceries/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
System.err: Calling js method onActivityResumed failed
System.err:
System.err: Error: No NgModule metadata found for 'AppModule'.
System.err: File: "file:///data/data/org.nativescript.Groceries/files/app/bundle.js, line: 14404, column: 16
System.err:
System.err: StackTrace:
System.err:     Frame: function:'ZoneAwareError', file:'file:///data/data/org.nativescript.Groceries/files/app/vendor.js', line: 58488, column: 33

complete log is here

问题:

我做错了什么?

以下是核心文件:

main.ts

import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { setStatusBarColors } from "./utils/status-bar-util";

import { AppModule } from "./app.module";
setStatusBarColors();

platformNativeScriptDynamic().bootstrapModule(AppModule);

app.module.ts

import {NgModule, NO_ERRORS_SCHEMA} from "@angular/core";
import {NativeScriptModule} from "nativescript-angular/nativescript.module";
import {NativeScriptFormsModule} from "nativescript-angular/forms";
import {AppComponent} from "./app.component";
import {NativeScriptHttpModule} from "nativescript-angular/http";
import {NativeScriptRouterModule} from "nativescript-angular/router";
import {routes, navigatableComponents} from "./app.routing";

@NgModule({
    imports: [NativeScriptModule, NativeScriptFormsModule, NativeScriptHttpModule, NativeScriptRouterModule,
        NativeScriptRouterModule.forRoot(routes)],
    declarations: [AppComponent, ...navigatableComponents],
    bootstrap: [AppComponent],
    schemas: [
        NO_ERRORS_SCHEMA
    ]
})
export class AppModule
{
}

app.component.ts

import { Component } from "@angular/core";

@Component({
    moduleId: module.id,
    selector: "main",
    template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent {}

login.component.ts

import {Component, ElementRef, OnInit, ViewChild} from "@angular/core";
import {User} from "../../shared/user/user";
import {UserService} from "../../shared/user/user.service";
import {Router} from "@angular/router";
import {RouterExtensions} from "nativescript-angular";
import {Page} from "ui/page";
import {View} from "ui/core/view"
import {Color} from "color";
import { setHintColor } from "../../utils/hint-util";
import { TextField } from "ui/text-field";
@Component({
    selector: "my-app",
    templateUrl: "./login.html",
    moduleId: module.id,
    styleUrls: ["./login-common.css", "./login.css"],
    providers: [UserService]
})
export class LoginComponent implements OnInit
{

list.component.ts

import {Component, ElementRef, OnInit, ViewChild} from "@angular/core";
import {Grocery} from "../../shared/grocery/grocery";
import {GroceryListService} from "../../shared/grocery/grocery-list.service";
import {TextField} from "ui/text-field";
import * as SocialShare from "nativescript-social-share";
@Component({
    selector: "list",
    moduleId: module.id,
    providers: [GroceryListService],
    templateUrl: "./list.html",
    styleUrls: ["./list-common.css", "./list.css"]
})
export class ListComponent implements OnInit
{...

更多文件:

webpack.config.jshttp://jsbin.com/yoyekutame/edit?html,output

Package.jsonhttp://jsbin.com/roleliqefa/edit?html

tsconfig.jsonhttp://jsbin.com/caxihereje/edit?html

0 个答案:

没有答案