离子生成错误-意外的令牌,缺少适当的加载程序

时间:2019-03-09 11:08:06

标签: javascript ionic-framework

仅在尝试访问特定页面(事件页面)时,才尝试生成以下错误。所有其他页面都可以正常工作。抱歉,很长的帖子,但是我不知道该如何解决。我删除了ios和android platorms ionic cordova platform rm ios,清理了npm缓存,但一无所获。

奇怪的是,我清理了事件页面,删除了ios应用ionic cordova platform rm ios并将其添加回... add ios。没有任何内容,即使我删除了<ion-header no-border [class]="headerBackgroundClass">,错误仍然显示[class]="headerBackgroundClass"。那是我清理npm缓存的时间。但这仍然没用

我不知道还能尝试什么。

我唯一能想到的就是将离子网络视图从"cordova-plugin-ionic-webview": "^4.0.0",更新为"cordova-plugin-ionic-webview": "^1.1.19",

[12:48:28]  ionic-app-script task: "build" 
[12:48:28]  Error: ./src/pages/event/event Module parse failed: Unexpected token (1:0) You may need an appropriate 
            loader to handle this file type. | <ion-header no-border [class]="headerBackgroundClass"> | <ion-navbar> | 
            <ion-title *ngIf="showTitle == true"> @ ./src/pages/event/event.module.ts 9:0-36 @ ./src lazy @ 
            ./node_modules/ionic-angular/util/ng-module-loader.js @ ./node_modules/ionic-angular/module.js @ 
            ./node_modules/ionic-angular/index.js @ ./src/app/app.module.ts @ ./src/app/main.ts 
Error: ./src/pages/event/event
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
| <ion-header no-border [class]="headerBackgroundClass">
|   <ion-navbar>
|     <ion-title *ngIf="showTitle == true">
 @ ./src/pages/event/event.module.ts 9:0-36
 @ ./src lazy
 @ ./node_modules/ionic-angular/util/ng-module-loader.js
 @ ./node_modules/ionic-angular/module.js
 @ ./node_modules/ionic-angular/index.js
 @ ./src/app/app.module.ts
 @ ./src/app/main.ts

package.json

"dependencies": {
    "@angular/animations": "5.2.10",
    "@angular/common": "5.2.10",
    "@angular/compiler": "5.2.10",
    "@angular/compiler-cli": "5.2.10",
    "@angular/core": "5.2.10",
    "@angular/forms": "5.2.10",
    "@angular/http": "5.2.10",
    "@angular/platform-browser": "5.2.10",
    "@angular/platform-browser-dynamic": "5.2.10",
    "@ionic-native/camera": "^4.11.0",
    "@ionic-native/core": "4.7.0",
    "@ionic-native/crop": "^4.12.0",
    "@ionic-native/file": "^4.12.0",
    "@ionic-native/google-plus": "^4.20.0",
    "@ionic-native/image-resizer": "^4.12.0",
    "@ionic-native/in-app-browser": "^4.17.0",
    "@ionic-native/native-page-transitions": "^4.18.0",
    "@ionic-native/onesignal": "^4.7.0",
    "@ionic-native/splash-screen": "4.7.0",
    "@ionic-native/status-bar": "^4.7.0",
    "@ionic/storage": "2.1.3",
    "angularfire2": "5.0.0-rc.6",
    "com.telerik.plugins.nativepagetransitions": "^0.6.5",
    "cordova-android": "7.1.4",
    "cordova-ios": "4.5.5",
    "cordova-plugin-camera": "^4.0.3",
    "cordova-plugin-crop": "^0.4.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-googleplus": "7.0.0",
    "cordova-plugin-inappbrowser": "^3.0.0",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^4.0.0",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "firebase": "4.12.1",
    "info.protonet.imageresizer": "^0.1.1",
    "ionic-angular": "3.9.2",
    "ionicons": "3.0.0",
    "moment": "^2.22.1",
    "onesignal-cordova-plugin": "^2.3.3",
    "rxjs": "5.5.10",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.26"
  },
  "config": {
    "ionic_source_map": "source-map"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.3",
    "typescript": "~2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {},
      "cordova-plugin-ionic-keyboard": {},
      "onesignal-cordova-plugin": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-camera": {},
      "cordova-plugin-crop": {},
      "info.protonet.imageresizer": {},
      "cordova-plugin-file": {},
      "cordova-plugin-inappbrowser": {},
      "com.telerik.plugins.nativepagetransitions": {},
      "cordova-plugin-googleplus": {
        "REVERSED_CLIENT_ID": "xxx",
        "PLAY_SERVICES_VERSION": "11.8.0"
      }
    },
    "platforms": [
      "android",
      "ios"
    ]

event.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { EventPage } from './event';
import { SaferPipe } from '../../pipes/safer.pipe';
import { Underscore } from '../../pipes/underscore.pipe';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { NativePageTransitions } from '@ionic-native/native-page-transitions';
import { DaysPipe } from '../../pipes/days.pipe';

import { HourPipe } from '../../pipes/hour.pipe';

@NgModule({
  declarations: [
    EventPage,
    SaferPipe,
    Underscore,
    DaysPipe,
    HourPipe
  ],
  providers: [
    InAppBrowser,
    NativePageTransitions
  ],
  imports: [

    IonicPageModule.forChild(EventPage),
  ],
})
export class EventPageModule { }

编辑***

使用替代方法使其正常工作。创建了一个新组件,并对代码进行了较小的更改。现在一切正常。不知道是什么导致了错误。

2 个答案:

答案 0 :(得分:0)

此消息Error: ./src/pages/event/event Module parse failed:使我认为EventPage组件错误地引用了其模板文件。

您的EventPage装饰器应如下所示:

@Component({
    selector: 'event-page',
    templateUrl: 'event.html'
})
export class EventPage {

检查:

  1. 事件页面模板文件的扩展名为.html,例如event.html
  2. 确保在页面装饰器中使用.html扩展名:templateUrl: 'event.html' templateUrl: 'event'
  3. 引用模板

答案 1 :(得分:0)

使用替代方法使其正常工作。创建了一个新组件,并对代码进行了较小的更改。现在一切正常。不知道是什么导致了错误。