HelloWorldModule不是NgModule,HelloWorldModule是UMD NPM模块

时间:2017-08-21 14:06:33

标签: angular typescript umd

这是我的HelloWorldModule UMD:

    (function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router')) :
    typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/router'], factory) :
    (factory((global['hello-world-app'] = {}),global.vendor._angular_core,global.vendor._angular_router));
}(this, (function (exports,_angular_core,_angular_router) { 'use strict';

function __decorate(decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
}

function __metadata(k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
}

var HelloWorldComponent = (function () {
    function HelloWorldComponent() {
    }
    HelloWorldComponent = __decorate([
        _angular_core.Component({
            template: "<h1>Hello, world!</h1>\n<p>You have reached the hello world component</p>"
        }), 
        __metadata('design:paramtypes', [])
    ], HelloWorldComponent);
    return HelloWorldComponent;
}());

//export const HelloWorldRoutes = [{ path: '', component: HelloWorldComponent }]
var HelloWorldModule = (function () {
    function HelloWorldModule() {
    }
    HelloWorldModule = __decorate([
        _angular_core.NgModule({
            declarations: [
                HelloWorldComponent
            ],
            imports: [
                _angular_router.RouterModule.forChild([{ path: '', component: HelloWorldComponent }])
            ],
            exports: [_angular_router.RouterModule]
        }), 
        __metadata('design:paramtypes', [])
    ], HelloWorldModule);
    return HelloWorldModule;
}());

exports.HelloWorldModule = HelloWorldModule;
exports.HelloWorldComponent = HelloWorldComponent;

Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=hello-world-app.umd.js.map

当我将其导入我的Angular应用程序项目并运行ng build时,我收到以下错误:

ERROR in HelloWorldModule is not an NgModule

以下是我的角度应用程序的依赖项:

  "dependencies": {
    "@angular/common": "4.3.4",
    "@angular/core": "4.3.4",
    "@angular/forms": "4.3.4",
    "@angular/http": "4.3.4",
    "@angular/platform-browser": "4.3.4",
    "@angular/platform-browser-dynamic": "4.3.4",
    "@angular/router": "4.3.4",
    "core-js": "^2.4.1",
    "hello-world-app-npm": "file:../hello-world-app-npm/hello-world-app-npm-1.0.0.tgz",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.3.1",
    "@angular/compiler": "4.3.4",
    "@angular/compiler-cli": "4.3.4",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.4.0"
  }

我的应用程序或UMD有问题吗?我该如何解决这个问题?

0 个答案:

没有答案