angular - 从 Ionic 2 更新到 Ionic 3,现在由于 "Unexpected token {"错误而无法构建

标签 angular typescript ionic2 ionic3

完成 Ionic 博客 ( detailed here ) 中定义的升级步骤后,我不会因为某个地方出现关于无效语法的非常不详细的错误消息而无法构建我的 Ionic 项目。这是完整的错误:

[14:16:31]  ionic-app-script task: "build" 
[14:16:31]  SyntaxError: Unexpected token { 
SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (\node_modules\@angular-devkit\build-optimizer\src\build-optimizer\webpack-loader.js:12:27)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)

我尝试使用上面的详细信息进行调试,但没有取得任何进展。在出现此错误之前,除了上面详细说明的内容之外,我没有进行任何更改(也许我错过了一些东西?)。有什么想法吗?

package.json

{
    "name": "com.myapp.test",
    "author": "",
    "homepage": "",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve",
        "watch": "ionic-app-scripts watch"
    },
    "dependencies": {
        "@angular/common": "4.4.3",
        "@angular/compiler": "4.4.3",
        "@angular/compiler-cli": "4.4.3",
        "@angular/core": "4.4.3",
        "@angular/forms": "4.4.3",
        "@angular/http": "4.4.3",
        "@angular/platform-browser": "4.4.3",
        "@angular/platform-browser-dynamic": "4.4.3",
        "@ionic-native/core": "4.3.1",
        "@ionic-native/splash-screen": "4.3.1",
        "@ionic-native/status-bar": "4.3.1",
        "@ionic/storage": "2.0.1",
        "font-awesome": "4.7.0",
        "ionic-angular": "3.7.1",
        "ionicons": "3.0.0",
        "node-sass": "^4.5.3",
        "rxjs": "5.4.3",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "3.0.0",
        "typescript": "2.3.4"
    },
    "description": "",
    "cordovaPlugins": [],
    "cordovaPlatforms": [],
    "-vs-binding": {
        "BeforeBuild": [
            "ionic:build"
        ]
    },
    "config": {
        "ionic_copy": "./config/copy.config.js",
        "ionic_sass": "./config/sass.config.js"
    }
}

来自 ionic 信息的输出

cli packages: (C:\Users\me\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.13.0
    ionic (Ionic CLI) : 3.13.0

local packages:

    @ionic/app-scripts : 3.0.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    Node : v6.10.3
    npm  : 4.6.1
    OS   : Windows 10

Misc:

    backend : pro

最佳答案

根据您的 Ionic 信息,您没有 Android SDK 工具。所以你需要安装它。

我正在使用 Android SDK 工具:25.2.5

并且您还需要安装cordova

这是我的详细信息:

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

Cordova Platforms  : android 6.2.3

查看如何setup Ionic 3 environment

关于angular - 从 Ionic 2 更新到 Ionic 3,现在由于 "Unexpected token {"错误而无法构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46716631/

相关文章:

angular - 如何使用 D3js 和 Angular 7 构建一个简单的 donut chart

angular - 无法正确使用继承 Ionic 2

angular - Ionic/Angular类设计模式

angular - 侧边菜单和页面在再次设置根页面后没有响应 Ionic 2 Beta 11

angular - 用于处理Hadoop数据的UI框架

javascript - 监视没有对象的函数

angular - 在组件中处理成功的 Action 分派(dispatch)

typescript - 将数组参数类型映射到数组返回类型?

javascript - TypeError : axios. get 不是一个函数?

angular - ng build --prod index.html 文件没有生成后?