首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误: node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerComponent类型是两个模块声明的一部分

错误: node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerComponent类型是两个模块声明的一部分
EN

Stack Overflow用户
提问于 2018-02-11 19:20:06
回答 1查看 5K关注 0票数 0

在尝试ionic cordova build android --prod --release时,我遇到了这个错误,使用ionic serveionic cordova run android,应用程序运行良好。

错误: C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerComponent类型是两个模块声明的一部分: C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerModule和C:/app/src/pages/document-pdf/document-pdf.module.ts!中的PdfModalPageModule请考虑将C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerComponent移到在C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中导入PdfViewerModule并在C:/app/src/pages/document-pdf/document-pdf.module.ts.中导入PdfModalPageModule的更高模块您还可以在C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中创建导出和包含PdfViewerComponent的新NgModule,然后在C:/app/node_modules/ng2-pdf-viewer/ng2-pdf-viewer.d.ts中的PdfViewerModule中导入NgModule,在C:/app/src/pages/document-pdf/document-pdf.module.ts.中导入PdfModalPageModule

我只在document-pdf.module.ts中导入ng-pdf-查看器,而不是在app.module.ts中。

代码语言:javascript
复制
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {PdfModalPage} from "./document-pdf";
import {PdfViewerComponent} from "ng2-pdf-viewer";

@NgModule({
    declarations: [PdfModalPage, PdfViewerComponent],
    imports: [IonicPageModule.forChild(PdfModalPage)],
})
export class PdfModalPageModule {}

角离子版

代码语言:javascript
复制
{
  "name": "Test",
  "version": "0.0.1",
  "description": "",
  "license": "Apache-2.0",
  "scripts": {
    "build": "ionic-app-scripts build",
    "clean": "ionic-app-scripts clean",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve",
    "i18n": "ng-xi18n"
  },
  "dependencies": {
    "@angular/common": "4.4.6",
    "@angular/compiler": "4.4.6",
    "@angular/compiler-cli": "4.4.6",
    "@angular/core": "4.4.6",
    "@angular/forms": "4.4.6",
    "@angular/http": "4.4.6",
    "@angular/platform-browser": "4.4.6",
    "@angular/platform-browser-dynamic": "4.4.6",
    "@ionic-native/app-version": "4.5.2",
    "@ionic-native/background-mode": "^4.5.3",
    "@ionic-native/contacts": "4.5.2",
    "@ionic-native/core": "3.14.0",
    "@ionic-native/device": "4.5.2",
    "@ionic-native/diagnostic": "^4.5.2",
    "@ionic-native/file": "4.5.2",
    "@ionic-native/file-chooser": "4.5.2",
    "@ionic-native/file-path": "4.5.2",
    "@ionic-native/firebase": "^4.5.3",
    "@ionic-native/in-app-browser": "3.14.0",
    "@ionic-native/media": "4.5.2",
    "@ionic-native/media-capture": "4.5.2",
    "@ionic-native/network": "^4.5.2",
    "@ionic-native/onesignal": "4.5.2",
    "@ionic-native/screen-orientation": "4.5.2",
    "@ionic-native/sim": "4.5.2",
    "@ionic-native/splash-screen": "3.14.0",
    "@ionic-native/sqlite": "^4.5.2",
    "@ionic-native/status-bar": "3.14.0",
    "@ionic-native/unique-device-id": "4.5.2",
    "@ionic-native/video-editor": "^4.5.2",
    "@ionic-native/video-player": "^4.5.2",
    "@ionic/pro": "^1.0.16",
    "@ionic/storage": "2.0.1",
    "angular2-moment": "1.7.0",
    "angular2-signaturepad": "2.6.1",
    "angularfire2": "^5.0.0-rc.3",
    "com-badrit-base64": "^0.2.0",
    "cordova-android": "^6.4.0",
    "cordova-ios": "^4.5.4",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-background-mode": "^0.7.2",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-contacts": "^2.3.1",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-file": "^4.3.3",
    "cordova-plugin-filechooser": "^1.0.1",
    "cordova-plugin-filepath": "^1.2.0",
    "cordova-plugin-firebase": "^0.1.25",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-ionic": "^3.1.0",
    "cordova-plugin-media": "^3.0.1",
    "cordova-plugin-media-capture": "^1.4.3",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-screen-orientation": "^2.0.2",
    "cordova-plugin-sim": "^1.3.3",
    "cordova-plugin-splashscreen": "^4.1.0",
    "cordova-plugin-statusbar": "^2.4.1",
    "cordova-plugin-video-editor": "^1.1.3",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.2.0",
    "cordova.plugins.diagnostic": "^3.9.2",
    "es6-promise-plugin": "^4.2.2",
    "firebase": "^4.9.1",
    "ionic-angular": "3.9.2",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionic2-auto-complete": "1.6.2-alpha",
    "ionicons": "3.0.0",
    "ng2-pdf-viewer": "4.1.0",
    "ng2-timeago": "1.0.7",
    "onesignal-cordova-plugin": "^2.2.5",
    "rxjs": "5.5.5",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.18"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.1.8",
    "ionic": "3.19.1",
    "typescript": "2.6.2"
  },
  "config": {},
  "cordova": {
    "platforms": [
      "android",
      "ios"
    ],
    "plugins": {
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-file": {},
      "cordova-plugin-filechooser": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-filepath": {},
      "onesignal-cordova-plugin": {},
      "cordova-plugin-media-capture": {},
      "cordova-plugin-screen-orientation": {},
      "cordova-plugin-media": {},
      "cordova-plugin-contacts": {},
      "cordova-plugin-sim": {},
      "com-badrit-base64": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-video-editor": {},
      "cordova-sqlite-storage": {},
      "cordova.plugins.diagnostic": {},
      "cordova-plugin-firebase": {},
      "cordova-plugin-background-mode": {}
    }
  }
}

离子信息

代码语言:javascript
复制
cli packages: (C:\app\node_modules)
@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:
cordova (Cordova CLI) : 7.1.0

local packages:
@ionic/app-scripts : 3.1.8
Cordova Platforms  : android 6.4.0
Ionic Framework    : ionic-angular 3.9.2

我尝试了一个新的安装,删除了/platforms /www /plugins和/node_modules

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-11 20:05:47

您应该在您的PdfViewerModule中导入document-pdf.module.ts,而不是在其中声明PdfViewerComponent,因为它已经在PdfViewerModule中声明了。

更新:您的模块应该是这样的:

代码语言:javascript
复制
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {PdfModalPage} from "./document-pdf";
import { PdfViewerModule } from 'ng2-pdf-viewer';
@NgModule({
    declarations: [PdfModalPage],
    imports: [IonicPageModule.forChild(PdfModalPage), PdfViewerModule]
})
export class PdfModalPageModule {}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48735461

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档