由于外部库而在构建时出现角度错误-意外值“ BannerModule ...”

时间:2018-06-22 12:41:32

标签: javascript angular angular5 ng-packagr angular-library

我创建了一个库,以便使用ng-packagr模块在两个不同的项目之间共享某些组件。

库的结构是 enter image description here

在我的书架中

src / package.json:

{
  "name": "my-ng-library",
  "version": "0.0.0",
  "license": "MIT",
  "ngPackage": {
    "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
    "lib": {
      "entryFile": "index.ts"
    },
    "dest": "../dist"
  },
  "private": false,
  "dependencies": {},
  "peerDependencies": {
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@angular/common": "^5.2.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19",
    "compass-mixins": "^0.12.10"
  }
}

src / components / banner / banner.module.ts:

import { BannerComponent } from './banner.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

@NgModule({
  imports: [CommonModule],
  declarations: [BannerComponent],
  exports: [BannerComponent],
  providers: []
})
export class BannerModule { }

src / index.ts:

export { BannerModule } from './components/banner/banner.module';
export { BannerComponent } from './components/banner/banner.component';

在客户端应用中

app.module.ts:

import { BannerModule } from 'my-ng-library/dist';
@NgModule({
  declarations:[
    BannerComponent
  ],
  imports: [
    BannerModule  
  ]
})

一切正常,可以在本地运行该应用程序,但是当我尝试为产品构建时,出现以下错误:

  

错误:意外值'/Users/username/Dev/Work/app-mobile-network-site/node_modules/my-ng-library/dist/components/banner/banner.module.d.ts中的BannerModule'由模块“ /Users/username/Dev/Work/Essence/app-mobile-network-site/src/app/app.module.ts中的AppModule”导入。请添加@NgModule批注。

0 个答案:

没有答案