部署Ionic2应用程序

时间:2018-03-02 16:13:56

标签: angular ionic2

当我在生产服务器上部署离子2应用程序时,我收到以下错误。但是当我在localhost上运行应用程序时,运行正常。

vendor.js:1349 Uncaught SyntaxError: Unexpected token ?
main.js:1 Uncaught ReferenceError: webpackJsonp is not defined
    at main.js:1

以下是我的index.html:

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
  <script data-ionic="inject">
    (function(w){var i=w.Ionic=w.Ionic||{};i.version='3.9.2';i.angular='5.0.3';i.staticDir='build/';})(window);
  </script>
  <meta charset="UTF-8">
  <title>Ionic App</title>
  <meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <meta name="format-detection" content="telephone=no">
  <meta name="msapplication-tap-highlight" content="no">

  <link rel="icon" type="image/x-icon" href="assets/icon/favicon.ico">
  <link rel="manifest" href="manifest.json">
  <meta name="theme-color" content="#4e8ef7">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <script src="cordova.js"></script>

  <link href="build/main.css" rel="stylesheet">

</head>
<body>
  <ion-app></ion-app>
  <script src="build/polyfills.js"></script>
  <script src="build/vendor.js"></script>
  <script src="build/main.js"></script>

</body>
</html>

这是我的package.json:

{
    "name": "WJC",
    "version": "0.0.1",
    "author": "Ionic Framework",
    "homepage": "http://ionicframework.com/",
    "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"
    },
    "dependencies": {
        "@angular/common": "5.0.3",
        "@angular/compiler": "5.0.3",
        "@angular/compiler-cli": "5.0.3",
        "@angular/core": "5.0.3",
        "@angular/forms": "5.0.3",
        "@angular/http": "5.0.3",
        "@angular/platform-browser": "5.0.3",
        "@angular/platform-browser-dynamic": "5.0.3",
        "@ionic-native/core": "4.4.0",
        "@ionic-native/in-app-browser": "^4.5.3",
        "@ionic-native/splash-screen": "4.4.0",
        "@ionic-native/status-bar": "4.4.0",
        "@ionic/storage": "2.1.3",
        "cordova-plugin-inappbrowser": "^2.0.2",
        "ionic-angular": "3.9.2", <=== latest
        "ionicons": "3.0.0",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@ionic/app-scripts": "3.1.8",
        "typescript": "2.4.2"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-inappbrowser": {}
        }
    }
}

我不确定我是否使用了一些不兼容的版本类型。

我将我的www文件夹的内容复制到我的Web应用程序中,然后我制作一个war文件并在运行tomcat的服务器上部署。 离子构建来自

  

离子服务

然后对于war文件我做maven安装。

这个package.json似乎正在运行,这是我几个月前创建的另一个应用程序。正如您所看到的,离子版本比我正在使用的最新版本有点旧版本在应用程序中引用但不起作用。

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "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"
  },
  "dependencies": {
    "@angular/animations": "^4.2.3",
    "@angular/common": "^4.2.3",
    "@angular/compiler": "^4.2.3",
    "@angular/compiler-cli": "^4.2.3",
    "@angular/core": "^4.2.3",
    "@angular/forms": "^4.2.3",
    "@angular/http": "^4.2.3",
    "@angular/platform-browser": "^4.2.3",
    "@angular/platform-browser-dynamic": "^4.2.3",
    "@angular/platform-server": "^4.2.3",
    "@angular/router": "^4.2.3",
    "@ionic-native/core": "^3.12.1", 
    "@ionic-native/splash-screen": "^3.12.1",
    "@ionic-native/status-bar": "^3.12.1",
    "@ionic/storage": "2.0.0",
    "angular2-moment": "^1.3.3",
    "angularfire2": "^4.0.0-rc.0",
    "cordova-android": "^6.3.0",
    "cordova-plugin-browsertab": "^0.2.0",
    "cordova-plugin-buildinfo": "^2.0.1",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.0.5",
    "cordova-plugin-device": "^1.1.4",
    "cordova-plugin-inappbrowser": "^1.7.2",
    "cordova-plugin-splashscreen": "^4.0.3",
    "cordova-plugin-statusbar": "^2.2.1",
    "cordova-plugin-whitelist": "^1.3.1",
    "cordova-universal-links-plugin": "^1.2.1",
    "firebase": "4.1.0",
    "ionic-angular": "^3.4.2", <=== Older
    "ionic-native": "2.4.1",
    "ionic-plugin-keyboard": "^2.2.1",
    "ionicons": "3.0.0",
    "material-design-icons": "^3.0.1",
    "moment": "^2.18.1",
    "moment-timezone": "^0.5.13",
    "ng2-pdf-viewer": "^2.0.2",
    "noman.arain.plugin": "file:../noman.arain.plugin",
    "rxjs": "5.5.2",
    "sw-toolbox": "3.6.0",
    "typescript": "^2.5.3",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.3.7",
    "@types/moment": "^2.13.0",
    "@types/moment-timezone": "^0.2.34",
    "ionic": "3.7.0",
    "typescript": "^2.3.4"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "myAwesomeApp: An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-splashscreen": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-console": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "noman.arain.plugin": {},
      "cordova-plugin-buildinfo": {},
      "cordova-universal-links-plugin": {},
      "cordova-plugin-browsertab": {},
      "cordova-plugin-inappbrowser": {}
    },
    "platforms": [
      "android"
    ]
  }
}

我的问题与serviceWorker无关。 我不想运行这两个命令:

ionic cordova platform add browser
ionic build browser --prod --release
当我想部署我的应用程序时,

离子服务应该足够了。 请删除此作为另一个的副本。

0 个答案:

没有答案