npm run ionic:build --prod给出了奇怪的错误

时间:2018-04-22 13:51:13

标签: angular ionic-framework ionic2 ionic3

当我尝试运行npm run ionic:build --prod时,它会给我以下错误:

  

错误:无法确定OverlayPortal类的模块   F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/overlay-portal.d.ts!   将OverlayPortal添加到NgModule以修复它。无法确定IonicApp类的模块   F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/app-root.d.ts!加   IonicApp到NgModule修复它。无法确定类ClickBlock的模块   F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/click-block.d.ts!   将ClickBlock添加到NgModule以修复它。无法确定类Slides的模块   F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/slides/slides.d.ts!加   滑到NgModule来修复它。

现在,如果我尝试使用以下代码将其包含在app.module.ts中:

import { OverlayPortal } from '../../node_modules/ionic-angular/umd/components/app/overlay-portal.d';

@NgModule({
  declarations: [
    OverlayPortal, //for aot compilation

关于做ionic serve我得到的错误是 -

  

模块构建失败:错误:ENOENT:没有这样的文件或目录,打开&f; \ D \ IONIC \ quicktask \ quicktask-web-froala \ node_modules \ ionic-angular \ umd \ components \ app \ overlay -portal.d.js'       在错误(本机)

如何使用--prod进行构建并使用ionic-serve运行而不会出现任何错误。

请告知。

编辑 - 1

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { App, NavController,  IonicErrorHandler, IonicModule,IonicApp } from 'ionic-angular'; // removed IonicApp from here

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { ListPage } from '../pages/list/list';
import { LoginPage } from '../pages/login/login';
import { NewtaskPage } from '../pages/newtask/newtask';
//import { DashboardPage } from '../pages/dashboard/dashboard';
import { TaskgivenPage } from '../pages/taskgiven/taskgiven';
import { MytaskPage } from '../pages/mytask/mytask';

import { CommunicationPage } from '../pages/communication/communication';


import { CommunicationgivenPage } from '../pages/communicationgiven/communicationgiven';
import { CommunicationreportPage } from '../pages/communicationreport/communicationreport';
import { GivencommunicationclosedPage } from '../pages/givencommunicationclosed/givencommunicationclosed';

import { TestPage } from '../pages/test/test';
import { LogoutPage } from '../pages/logout/logout';
import { MyclosedtaskPage } from '../pages/myclosedtask/myclosedtask';
import { GivenclosedtaskPage } from '../pages/givenclosedtask/givenclosedtask';
import { ReporttoPage } from '../pages/reportto/reportto';
import { SlidePage } from '../pages/slide/slide';


import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
//import { Firebase } from '@ionic-native/firebase';
import { SpeechRecognition } from '@ionic-native/speech-recognition';


import { Headers, Http, HttpModule ,Response } from '@angular/http';
import { IonicStorageModule } from '@ionic/storage';

import { TimeAgoPipe } from 'time-ago-pipe';

import {Commopen} from '../pages/givencommunicationclosed/commopen';
import { Userimage } from '../pages/dashboard2/userimage';

import { MycommclosedPage } from '../pages/mycommclosed/mycommclosed';
import { Dashboard2Page } from '../pages/dashboard2/dashboard2';
import { MytaskuserwisePage } from '../pages/mytaskuserwise/mytaskuserwise';
import  { ProfilePage } from '../pages/profile/profile';
import { PaymentPage } from '../pages/payment/payment';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { InfoPage } from '../pages/info/info';
import { PerformancePage } from '../pages/performance/performance';
import { PopoverPage } from '../pages/communicationgiven/popover';
import { Updatepopup} from '../pages/communicationgiven/updatepopup';
import { TimelinePage } from '../pages/timeline/timeline';
import { Commpopup } from '../pages/timeline/commpopup';
import {SearchPage} from '../pages/search/search';
import {SuggestionPage} from '../pages/suggestion/suggestion';
import {Mytaskpopup} from '../pages/mytask/mytaskpopup';
import {Userwisepopup} from '../pages/mytaskuserwise/userwisepopup';
import {Taskgivenpopup} from '../pages/taskgiven/taskgivenpopup';
import {Reportpopup} from '../pages/reportto/reportpopup';
import {FollowerPage} from '../pages/follower/follower';
import {CommfollowerPage} from '../pages/commfollower/commfollower';
import { CommPage } from '../pages/comm/comm';
import {ReportsPage} from '../pages/reports/reports';
import { DashmodalPage } from '../pages/dashmodal/dashmodal';
import { Dashmodal1Page } from '../pages/dashmodal1/dashmodal1';
import { LabelPage } from '../pages/label/label';
import { SortPage } from '../pages/sort/sort';
import { SortuserwisePage } from '../pages/sortuserwise/sortuserwise';
import { LastseenPage } from '../pages/lastseen/lastseen';
import { MemolistPage } from '../pages/memolist/memolist';
import { OfcmemoPage } from '../pages/ofcmemo/ofcmemo';
import { CommadminPage } from '../pages/commadmin/commadmin';
import { AdminpcPage } from '../pages/adminpc/adminpc';

import {AiPage} from '../pages/ai/ai';
import { Autosize } from '../directives/autosize/autosize';

// Import Froala Editor.
import "froala-editor/js/froala_editor.pkgd.min.js";
import { NoSanitizePipe } from '../pipes/no-sanitize/no-sanitize';

// Import Angular2 plugin.
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
import {Nl2BrPipeModule} from 'nl2br-pipe';
import {LinkyModule} from 'angular-linky';

//Search
import { SelectSearchableModule } from 'ionic-select-searchable';

// for ionic build --prod errors or aot compilation
// import { OverlayPortal } from '../../node_modules/ionic-angular/umd/components/app/overlay-portal.d';
//import { IonicApp } from '../../node_modules/ionic-angular/umd/components/app/app-root.d';
//import { ClickBlock } from '../../node_modules/ionic-angular/umd/components/app/click-block.d';
//import { Slides } from '../../node_modules/ionic-angular/umd/components/slides/slides.d';
import { FilterArrayPipe } from '../pages/dashboard2/filterpipe';
import {IonicPage, NavParams, Slides} from 'ionic-angular';

@NgModule({
  declarations: [
  //  OverlayPortal, //for aot compilation
 //   IonicApp , //for aot compilation for app-root.d
  //  ClickBlock, //for aot compilation
  //  Slides, //for aot compilation
  IonicApp,
    FilterArrayPipe, //for aot compilation
    TimeAgoPipe,
    MyApp,
    HomePage,
    ListPage,
    LoginPage,
    NewtaskPage,
   // DashboardPage,
    TaskgivenPage,
    MytaskPage,
    CommunicationPage,
    CommunicationgivenPage,
CommunicationreportPage,
GivencommunicationclosedPage,    
    TestPage,
    LogoutPage,
    MyclosedtaskPage,
    GivenclosedtaskPage,
    ReporttoPage,
    Dashboard2Page,
    MytaskuserwisePage,
    MycommclosedPage,
    ProfilePage,
    PaymentPage,
    InfoPage,
    SlidePage,
    PerformancePage ,
    PopoverPage,
    Updatepopup,
    SearchPage,
    TimelinePage,
    Commpopup,
    SuggestionPage,
    Mytaskpopup,
    Userwisepopup,
    Taskgivenpopup,
    Reportpopup,
    AiPage,
    Autosize,
    NoSanitizePipe,
    FollowerPage,
    CommfollowerPage,
    CommPage,
    ReportsPage,
    DashmodalPage,
    Dashmodal1Page,
    LabelPage,
    SortPage,
    SortuserwisePage,
    LastseenPage,
    MemolistPage,
    OfcmemoPage,
    CommadminPage,
    AdminpcPage,
    //OverlayPortal
  ],
  imports: [
    BrowserModule,
    HttpModule,
    Nl2BrPipeModule,
    LinkyModule,
    SelectSearchableModule,
    IonicModule.forRoot(MyApp),
    FroalaEditorModule.forRoot(),
    FroalaViewModule.forRoot(),
    IonicStorageModule.forRoot()
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage,
    ListPage,
    LoginPage,
    NewtaskPage,
   // DashboardPage,
    TaskgivenPage,
    MytaskPage,
    CommunicationPage,
    CommunicationgivenPage,
    CommunicationreportPage, 
    GivencommunicationclosedPage,
    TestPage,
    LogoutPage,
    MyclosedtaskPage,
    GivenclosedtaskPage,
    ReporttoPage,
    Dashboard2Page,
    MytaskuserwisePage,
    MycommclosedPage,
    ProfilePage,
    PaymentPage,
    InfoPage,
    SlidePage,
    PerformancePage,
    PopoverPage,
    Updatepopup,
    SearchPage,
    TimelinePage,
    Commpopup,
    SuggestionPage,
    Mytaskpopup,
    Userwisepopup,
    Taskgivenpopup,
    Reportpopup,
    AiPage,
    FollowerPage,
    CommfollowerPage,
    CommPage,
    ReportsPage,
    DashmodalPage,
    Dashmodal1Page,
    LabelPage,
    SortPage,
    SortuserwisePage,
    LastseenPage,
    MemolistPage,
    OfcmemoPage,
    CommadminPage,
    AdminpcPage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    //Firebase,
    Commopen,
    GivenclosedtaskPage,
    Userimage,
    InAppBrowser,
    SpeechRecognition,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

4 个答案:

答案 0 :(得分:1)

您要导入的文件是this.zone.run(() => { //Here u do the stuff after the change detection is confirmed. }); 文件,其扩展名为type definitions

您应该从.d.js文件导入。检查文件夹,你应该得到它

答案 1 :(得分:0)

我遇到了同样的错误。对我而言,这是由于离子导入不一致(一些来自顶级ionic-angular,一些直接从组件导入,例如ionic-angular/components/loading/loading-controller)。

https://stackoverflow.com/a/50858210/6599076

答案 2 :(得分:0)

从 URL 中删除“umd”

import { OverlayPortal } from "../../node_modules/ionic-angular/components/app/overlay-portal.d";

更多信息 => Error: Cannot determine the module for class OverlayPortal in --prod

答案 3 :(得分:-1)

我解决了我的问题。在我的项目中,我使用了过时的模块ion-datepicker 如果您还使用同一问题,请按照以下步骤操作,找到并发现已感染或过时的模块。

1。第一步:

在项目中的所有文件中查找 from 'ionic-angular/

  1. 第二步:

如果您发现这个词像 import { xyz } from 'ionic-angular/xyz/abc'

更新该模块。

如果没有可用的更新,则可以删除该模块

npm uninstall ion-datepicker(or your defected module)

在此之后,您需要从app.module.ts中删除该模块,以及从那里使用remove的任何地方,之后您可以尝试

ionic cordova build android --prod --release

希望这会有所帮助。 谢谢