与离子2的OpenWeatherMap错误生产版本

与离子2的OpenWeatherMap错误生产版本

问题描述:

我正在尝试使用角度2和TS构建ionic2应用程序,构建处于生产模式,并且出现此错误。与离子2的OpenWeatherMap错误生产版本

Error: Unexpected value 'OpenWeatherMapModule in E:/Stage/VLT 
     APP/com.vlt.app/node_modules/ionic- 
openweathermap/dist/openweathermap.module.d.ts' imported by the module 
     'AppModule in E:/Stage/VLT APP/com.vlt.app/src/app/app.module.ts'. 
Please add a @NgModule annotation. 
Error: Unexpected value 'OpenWeatherMapModule in E:/Stage/VLT 
APP/com.vlt.app/node_modules/ionic- 
openweathermap/dist/openweathermap.module.d.ts' imported by the module 
'AppModule in E:/ 
Stage/VLT APP/com.vlt.app/src/app/app.module.ts'. Please add a @NgModule 
annotation. 

我在我的应用程序中使用OpenWeatherMap,我不知道为什么我只在生产模式下得到这个错误。除此之外,我不认为我需要编辑节点模块库目录中的任何文件。

编辑

这是我进口app.module.ts

@NgModule({ 
    declarations: [ 
    MyApp, 
    HomePage, 
    ListPage, 
    BestOffers, 
    excursion, 
    hotel, 
    circuit, 
    MapPage, 
    NosExcursion, 
    WeatherPage, 
    NosHotel, 
    NosCircuit, 
    CircuitPage, 
    ExcursionPage, 
    ImageModal, 
    SearchModal, 
    ResultModal, 
    PromoPage, 
    HotelPage, 
    GalleryPage, 
    GalleryModal, 
    ZoomableImage, 
    PopoverPage, 
    ReservationModal, 
    CurrencyChange, 
CircuitReservationModal, 
    ], 
    imports: [ 
    BrowserModule, 
    IonicModule.forRoot(MyApp), 
    HttpModule, 
    IonicStorageModule.forRoot(), 
    SuperTabsModule.forRoot(), 
    AgmCoreModule.forRoot({ 
     apiKey: '**********' 
    }), 
    TranslateModule.forRoot({ 
     loader: { 
     provide: TranslateLoader, 
     useFactory: (createTranslateLoader), 
     deps: [Http] 
     } 
    }), 
    IonicImageViewerModule, 
    OpenWeatherMapModule, 
    ], 
    bootstrap: [IonicApp], 
    entryComponents: [ 
    MyApp, 
    HomePage, 
    ListPage, 
    BestOffers, 
    excursion, 
    hotel, 
    circuit, 
    MapPage, 
    NosExcursion, 
    WeatherPage, 
    NosHotel, 
    NosCircuit, 
    CircuitPage, 
    HotelPage, 
    ExcursionPage, 
    ImageModal, 
    SearchModal, 
    ResultModal, 
    PromoPage, 
    GalleryPage, 
    GalleryModal, 
    PopoverPage, 
    ReservationModal, 
    CurrencyChange, 
    CircuitReservationModal, 
    ], 
    providers: [ 
    StatusBar, 
    SplashScreen, 
    {provide: ErrorHandler, useClass: IonicErrorHandler}, 
    SQLite, 
    HotelPage, 
    InAppBrowser, 
    ] 
}) 
export class AppModule {} 
export function createTranslateLoader(http: Http) { 
    return new TranslateHttpLoader(http, './assets/i18n/', '.json'); 
    } 

因此,任何帮助阵列?

+0

你能给完整的代码app.module.ts? – Mankeomorakort

+0

它在“离子发球”中起作用吗?哪些标志,你给生产建立例如:'aot','prod' – Dhyey

+0

它不会出现'Ionic serve'的错误,我给 - 生产建设的产品 –

经过一段时间的测试后,我得到了和你一样的问题。我认为这是openweathermap Module的问题。该模块中的文件结构看起来不正确。

enter image description here

所以在安装该模块的代替,我下载的源代码,包括我的离子样本如下:

enter image description here

home.html的

<ion-header> 
    <ion-navbar> 
    <button ion-button menuToggle> 
     <ion-icon name="menu"></ion-icon> 
    </button> 
    <ion-title>Home</ion-title> 
    </ion-navbar> 
</ion-header> 

<ion-content padding> 
    <openweathermap [options]="options"></openweathermap> 
</ion-content> 

home.ts

import { Component } from '@angular/core'; 
import { NavController } from 'ionic-angular'; 

@Component({ 
    selector: 'page-home', 
    templateUrl: 'home.html' 
}) 
export class HomePage { 
    options: any = {}; 

    constructor(public navCtrl: NavController) { 
    this.options = { 
      apikey: "6ff5deed8aaa46c2fdcb1bfddd2d4ecc", 
      city: { "name": ["Phnom Penh"] }, 
      unitFormat: "metric", 
      lang: "en" 
     } 
    } 
} 

这个例子的源代码可以在这里找到:ionic3-openweathermap

我希望这可以帮助您,谢谢:)

编辑

我在Android的生产测试它工作正常

+0

谢谢!我会测试这个,虽然我删除了模块,因为我发现自己没有使用它。 –