代码之家  ›  专栏  ›  技术社区  ›  exequielc

SyntaxError:意外令牌(异步等待[3]

  •  0
  • exequielc  · 技术社区  · 6 年前

    我在爱奥尼亚上有一个项目,它在浏览器上运行得很好,但在安卓设备上由于这个错误而失败。由于某些原因,函数async/await不起作用。

    我认为es2018应该是可行的。有人能看看我的配置吗?

    ionic cordova run android
    

    几秒钟后,这是AndroidStudio logcat的输出控制台

     "Uncaught SyntaxError: Unexpected identifier"
    
    08-05 16:03:36.417 32442-32442/chess.pidoweb I/chromium: [INFO:CONSOLE(1343)] "Uncaught SyntaxError: Unexpected identifier", source: http://192.168.0.85:8100/build/main.js (1343)
    

    错误在于此异步/等待函数

     async webGoogleLogin() {
            try {
               ... some code ..
            }
            catch (err) {
                console.log(err);
            }
        }
    

    配置:

    <?xml version='1.0' encoding='utf-8'?>
    <widget id="chess.pidoweb" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
        <name>Pido IONIC</name>
        <description>""</description>
        <author email="hi@ionicframework" href="http://ionicframework.com/" />
        <content src="index.html" />
        <access origin="*" />
        <allow-intent href="http://*/*" />
        <allow-intent href="https://*/*" />
        <allow-intent href="tel:*" />
        <allow-intent href="sms:*" />
        <allow-intent href="mailto:*" />
        <allow-intent href="geo:*" />
        <allow-navigation href="http://localhost:8100/*" />
        <allow-navigation href="http://*/*" />
        <allow-navigation href="tel:*" />
        <allow-navigation href="mailto:*" />
        <preference name="loadUrlTimeoutValue" value="700000" />
        <preference name="orientation" value="default" />
        <preference name="ScrollEnabled" value="false" />
        <preference name="StatusBarStyle" value="default" />
        <preference name="BackupWebStorage" value="none" />
        <preference name="android-minSdkVersion" value="19" />
        <preference name="SplashMaintainAspectRatio" value="true" />
        <preference name="FadeSplashScreenDuration" value="300" />
        <preference name="SplashShowOnlyFirstTime" value="false" />
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="3000" />
        <universal-links>
            <host name="https://n3q8p.app.goo.gl/jdXk" scheme="https" />
            <host name="AUTH_DOMAIN" scheme="https">
                <path url="/__/auth/callback" />
            </host>
        </universal-links>
        <platform name="android">
            <allow-intent href="market:*" />
            <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
            <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
            <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
            <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
            <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
            <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
            <icon src="resources/android/icon/drawable-xhdpi-icon.png" />
            <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png" />
            <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png" />
            <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png" />
            <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png" />
            <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png" />
            <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
        </platform>
        <platform name="ios">
            <allow-intent href="itms:*" />
            <allow-intent href="itms-apps:*" />
            <icon height="57" src="resources/ios/icon/icon.png" width="57" />
            <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
            <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
            <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
            <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
            <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
            <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
            <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
            <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
            <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
            <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
            <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
            <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
            <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
            <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
            <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
            <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
            <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
            <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
            <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
            <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
            <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
            <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
            <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
            <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
            <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        </platform>
        <plugin name="ionic-plugin-keyboard" spec="^2.2.1" />
        <plugin name="info.protonet.imageresizer" spec="~0.1.1" />
        <plugin name="cordova-plugin-console" spec="^1.1.0" />
        <plugin name="cordova-plugin-camera" spec="^4.0.2" />
        <plugin name="cordova-plugin-uniquedeviceid" />
        <plugin name="cordova-plugin-app-version" />
        <plugin name="cordova-plugin-ionic-keyboard" spec="^1.1.6" />
        <plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
        <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
        <plugin name="cordova-plugin-ionic-webview" spec="^1.2.1" />
        <plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
        <plugin name="cordova-plugin-device" spec="^2.0.2" />
        <plugin name="cordova-sqlite-storage" spec="^2.3.3" />
        <plugin name="cordova-plugin-googleplus" spec="^5.3.0">
            <variable name="REVERSED_CLIENT_ID" value="com.googleusercontent.apps.781145103219-a87b3bd7d7858i8lrr2531nm8ml2bj6c" />
            <variable name="WEB_APPLICATION_CLIENT_ID" value="781145103219-vn75hrm8tv0b54hkck4dokv5nnr0pvao.apps.googleusercontent.com" />
        </plugin>
        <plugin name="cordova-plugin-crosswalk-webview" spec="^2.4.0">
            <variable name="XWALK_VERSION" value="22+" />
            <variable name="XWALK_LITEVERSION" value="xwalk_core_library_canary:17+" />
            <variable name="XWALK_COMMANDLINE" value="--disable-pull-to-refresh-effect" />
            <variable name="XWALK_MODE" value="embedded" />
            <variable name="XWALK_MULTIPLEAPK" value="true" />
        </plugin>
        <plugin name="cordova-plugin-geolocation" spec="^2.4.3">
            <plugin name="cordova-plugin-nativestorage" spec="^2.3.2" />
            <variable name="GEOLOCATION_USAGE_DESCRIPTION" value=" " />
        </plugin>
        <plugin name="cordova-android-support-gradle-release">
            <variable name="ANDROID_SUPPORT_VERSION" value="27.+" />
        </plugin>
        <engine name="browser" spec="5.0.3" />
        <engine name="android" spec="7.0.0" />
    </widget>
    

    tsconfig.json

    {
      "atom": {
        "rewriteTsconfig": false
      },
      "parserOptions": {
        "ecmaVersion": 8,
        "sourceType": "module"
      },
      "compileOnSave": false,
      "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "declaration": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "lib": [
          "dom",
          "es2018"
        ],
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "target": "ES2018",
        "types" : ["node"],
        "typeRoots": [
          "node_modules/@types"
        ]
      },
      "include": [
        "src/**/*.ts"
      ],
      "exclude": [
        "node_modules",
        "src/**/*.spec.ts",
        "src/**/__tests__/*.ts"
      ]
    }
    

    package.json

    {
      "name": "pidoionic",
      "version": "0.0.2",
      "description": "",
      "private": true,
      "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
      },
      "config": {
        "ionic_webpack": "config/webpack.config.js"
      },
      "dependencies": {
        "@agm/core": "1.0.0-beta.3",
        "@angular/animations": "5.2.11",
        "@angular/common": "5.2.11",
        "@angular/compiler": "5.2.11",
        "@angular/compiler-cli": "5.2.11",
        "@angular/core": "5.2.11",
        "@angular/forms": "5.2.11",
        "@angular/http": "5.2.11",
        "@angular/platform-browser": "5.2.11",
        "@angular/platform-browser-dynamic": "5.2.11",
        "@ionic-native/app-version": "^4.10.1",
        "@ionic-native/camera": "4.11.0",
        "@ionic-native/core": "~4.11.0",
        "@ionic-native/device": "^4.7.0",
        "@ionic-native/file": "^4.7.0",
        "@ionic-native/firebase": "^4.7.0",
        "@ionic-native/google-analytics": "^4.11.0",
        "@ionic-native/google-plus": "^4.7.0",
        "@ionic-native/image-resizer": "^4.6.0",
        "@ionic-native/native-storage": "^4.11.0",
        "@ionic-native/splash-screen": "~4.11.0",
        "@ionic-native/sqlite": "^4.7.0",
        "@ionic-native/sqlite-porter": "^4.7.0",
        "@ionic-native/status-bar": "~4.11.0",
        "@ionic/pro": "2.0.3",
        "@ionic/storage": "^2.1.3",
        "@ngx-translate/core": "10.0.2",
        "@ngx-translate/http-loader": "^3.0.1",
        "@types/google-maps": "^3.2.0",
        "angularfire2": "^5.0.0-rc.5-next",
        "asyncawait": "^1.0.7",
        "cordova": "^8.0.0",
        "cordova-android": "7.0.0",
        "cordova-android-support-gradle-release": "^1.4.4",
        "cordova-browser": "5.0.3",
        "cordova-plugin-app-version": "^0.1.9",
        "cordova-plugin-camera": "^4.0.3",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-console": "^1.1.0",
        "cordova-plugin-crosswalk-webview": "^2.4.0",
        "cordova-plugin-device": "^2.0.2",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-firebase": "^1.0.0",
        "cordova-plugin-geolocation": "^2.4.3",
        "cordova-plugin-google-analytics": "^1.8.3",
        "cordova-plugin-googleplus": "^5.3.0",
        "cordova-plugin-ionic-keyboard": "^2.1.2",
        "cordova-plugin-ionic-webview": "^1.2.1",
        "cordova-plugin-media": "^5.0.2",
        "cordova-plugin-nativestorage": "^2.3.2",
        "cordova-plugin-splashscreen": "^5.0.2",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-uniquedeviceid": "^1.3.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "cordova-sqlite-storage": "^2.3.3",
        "firebase": "^4.13.1",
        "global": "^4.3.2",
        "imagemin": "^5.3.1",
        "info.protonet.imageresizer": "^0.1.1",
        "ionic-angular": "^3.9.2",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "4.2.6",
        "local-storage": "^1.4.2",
        "mercadopago": "^1.0.13",
        "moment": "^1.7.2",
        "ng2-reactive-forms-validators": "^1.1.0",
        "rxjs": "5.5.11",
        "sqlite3": "^4.0.0",
        "sw-toolbox": "3.6.0",
        "typeorm": "^0.2.7",
        "yarn": "^1.9.2",
        "zone.js": "0.8.26"
      },
      "devDependencies": {
        "@types/google.analytics": "0.0.39",
        "@types/googlemaps": "^3.30.11",
        "@types/node": "^10.5.4",
        "ionic": "3.9.2",
        "sql.js": "^0.5.0",
        "ts-node": "7.0.0",
        "@ionic/app-scripts": "3.1.11",
        "typescript": "^3.0.1"
      },
      "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-device",
        "cordova-plugin-statusbar",
        "cordova-plugin-console",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
      ],
      "cordovaPlatforms": [],
      "cordova": {
        "plugins": {
          "cordova-sqlite-storage": {},
          "cordova-plugin-geolocation": {
            "GEOLOCATION_USAGE_DESCRIPTION": " "
          },
          "cordova-plugin-console": {},
          "cordova-plugin-device": {},
          "cordova-plugin-splashscreen": {},
          "cordova-plugin-statusbar": {},
          "cordova-plugin-whitelist": {},
          "ionic-plugin-keyboard": {},
          "info.protonet.imageresizer": {},
          "cordova-plugin-camera": {},
          "cordova-plugin-googleplus": {
            "REVERSED_CLIENT_ID": "com.googleusercontent.apps.781145103219-a87b3bd7d7858i8lrr2531nm8ml2bj6c",
            "WEB_APPLICATION_CLIENT_ID": "781145103219-vn75hrm8tv0b54hkck4dokv5nnr0pvao.apps.googleusercontent.com"
          },
          "cordova-plugin-crosswalk-webview": {
            "XWALK_VERSION": "22+",
            "XWALK_LITEVERSION": "xwalk_core_library_canary:17+",
            "XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
            "XWALK_MODE": "embedded",
            "XWALK_MULTIPLEAPK": "true"
          },
          "cordova-plugin-ionic-webview": {},
          "cordova-plugin-uniquedeviceid": {},
          "cordova-plugin-app-version": {},
          "cordova-android-support-gradle-release": {
            "ANDROID_SUPPORT_VERSION": "27.+"
          },
          "cordova-plugin-ionic-keyboard": {},
          "cordova-plugin-nativestorage": {}
        },
        "platforms": [
          "browser",
          "android"
        ]
      }
    }
    

    离子信息

    Ionic:
    
       ionic (Ionic CLI)  : 3.9.2
       Ionic Framework    : ionic-angular 3.9.2
       @ionic/app-scripts : 3.1.11
    
    Cordova:
    
       cordova (Cordova CLI) : not installed
       Cordova Platforms     : not available
    
    System:
    
       NodeJS : v8.11.1 (D:\nodejs\node.exe)
       npm    : 5.6.0
       OS     : Windows 10
    
    Environment:
    
       ANDROID_HOME : not set
    
    0 回复  |  直到 6 年前