[英]npm run ionic:build --prod giving strange error
當我嘗試運行npm run ionic:build --prod
,它給了我以下錯誤:
錯誤:無法確定 F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/overlay-portal.d.ts 中類 OverlayPortal 的模塊! 將 OverlayPortal 添加到 NgModule 以修復它。 無法確定 F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/app-root.d.ts 中類 IonicApp 的模塊! 將 IonicApp 添加到 NgModule 以修復它。 無法確定 F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/app/click-block.d.ts 中類 ClickBlock 的模塊! 將 ClickBlock 添加到 NgModule 以修復它。 無法確定 F:/D/IONIC/quicktask/quicktask-web-froala/node_modules/ionic-angular/umd/components/slides/slides.d.ts 中 Slides 類的模塊! 將 Slides 添加到 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
運行而沒有任何錯誤。
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 {}
您用於導入的文件是擴展名為.d.js
的type definitions
文件。
您應該改為從.ts
文件導入。 檢查文件夾,你應該得到它
我遇到了同樣的錯誤。 對我來說,這是由於 Ionic 導入不一致(一些來自頂級ionic-angular
,一些直接從組件導入,例如ionic-angular/components/loading/loading-controller
)。
從 URL 中刪除“umd”
import { OverlayPortal } from "../../node_modules/ionic-angular/components/app/overlay-portal.d";
我解決了我的問題。 在我的項目中,我使用了一個過時的模塊ion-datepicker
。 如果您也遇到同樣的問題,您可以按照以下步驟查找受感染或過時的模塊。
1. 第一步:
在您的項目中找到from 'ionic-angular/
word from 'ionic-angular/
所有文件,
2. 第二步:
如果你發現這個詞像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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.