Ionic 4-WebApp显示错误找不到模块“。”运行ionic build --prod时

时间:2018-07-31 15:05:37

标签: javascript angular typescript ionic-framework webpack

好吧,我开始发布我的离子网络应用程序,但是从昨天开始我一直在迷惑这个问题。

这只在--prod上发生。如果我在使用离子服务的情况下可以正常工作。

在我的浏览器中查看控制台(chrome,firefox)时出现的错误是

Uncaught Error: Cannot find module "."
at vendor.js:1
at vendor.js:1
at Object.<anonymous> (vendor.js:1)
at e (vendor.js:1)
at Object.483 (main.js:1)
at e (vendor.js:1)
at Object.480 (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1

这是我的package.json:

  "dependencies": {
    "@agm/core": "1.0.0-beta.3",
    "@angular/animations": "5.2.9",
    "@angular/common": "5.2.9",
    "@angular/compiler": "5.2.9",
    "@angular/compiler-cli": "5.2.9",
    "@angular/core": "^5.2.9",
    "@angular/forms": "5.2.9",
    "@angular/http": "^5.2.9",
    "@angular/platform-browser": "5.2.9",
    "@angular/platform-browser-dynamic": "5.2.9",
    "@ionic-native/app-version": "^4.10.1",
    "@ionic-native/camera": "4.11.0",
    "@ionic-native/core": "^4.7.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/in-app-browser": "^4.7.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/storage": "2.1.3",
    "@ngx-translate/core": "8.0.0",
    "@ngx-translate/http-loader": "^2.0.0",
    "@types/google-maps": "^3.2.0",
    "angular2-google-maps": "0.17.0",
    "angularfire2": "^5.0.0-rc.5-next",
    "cordova": "^8.0.0",
    "cordova-android": "^6.2.3",
    "cordova-browser": "5.0.3",
    "cordova-plugin-camera": "^4.0.2",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-device": "^2.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.0.5",
    "cordova-plugin-ionic-webview": "^1.1.19",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.1",
    "cordova-plugin-whitelist": "^1.3.3",
    "cordova-sqlite-storage": "^2.3.0",
    "firebase": "^4.13.1",
    "imagemin": "^5.3.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.8",
    "sqlite3": "^4.0.0",
    "sw-toolbox": "3.6.0",
    "typeorm": "0.2.7",
    "yarn": "^1.9.2",
    "zone.js": "0.8.20"
  },
  "devDependencies": {
    "@angular/cli": "1.5.0",
    "@angular/flex-layout": "6.0.0-beta.17",
    "@angular/tsc-wrapped": "^4.4.6",
    "@ionic/app-scripts": "^3.1.11",
    "@types/google.analytics": "0.0.39",
    "@types/googlemaps": "^3.30.11",
    "@types/node": "^10.5.4",
    "ionic": "4.0.1",
    "sql.js": "^0.5.0",
    "ts-node": "7.0.0",
    "typescript": "2.1.7"
  },

tsconfig.json

    {
  "atom": {
    "rewriteTsconfig": false
  },
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noImplicitAny": false,
    "lib": [
      "dom",
      "es2017"
    ],

    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "ES2017",
    "types" : ["node"],
    "typeRoots": [
      "node_modules/@types"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules",
    "src/**/*.spec.ts",
    "src/**/__tests__/*.ts"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

不知道发生了什么。只有在运行ionic --prod时才会发生。

**

  

未捕获的错误:找不到模块“。在vendor.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.2.9';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">

   <!--cordova.js required for cordova apps (remove if not needed)-->
  <script src="cordova.js"></script>

  <!-- un-comment this code to enable service worker-->
  <script>
    if ('serviceWorker' in navigator) {
      navigator.serviceWorker.register('service-worker.js')
        .then(() => console.log('service worker installed'))
        .catch(err => console.error('Error', err));
    }
  </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>

0 个答案:

没有答案