Ionic Cordova Build prod:找不到模块“。” - 打字稿版本>3

Posted

技术标签:

【中文标题】Ionic Cordova Build prod:找不到模块“。” - 打字稿版本>3【英文标题】:Ionic Cordova Build prod: Cannot find module “.” - Typescript version >3 【发布时间】:2020-04-01 03:03:55 【问题描述】:

我已经更新了我的 ionic 项目和所有依赖项,现在当我尝试构建 --prod android apk 时出现以下错误:

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.<anonymous> (main.js:1)
at e (vendor.js:1)
at window.webpackJsonp (vendor.js:1)
at main.js:1
vendor.js:1 Ionic Native: deviceready event fired after 57 ms
assets/icon/favicon.ico:1 Failed to load resource: net::ERR_FILE_NOT_FOUND

我已经搜索了很多,问题似乎是打字稿版本(>3) 但是所有帖子都非常旧(2018 年),唯一的解决方案是将 Typescript 降级到 2.6 版 但这对我来说不是解决方案,因为我必须为 Firebase 使用 angular >= 7。

有没有合适的解决方案如何让它工作???

离子信息:

Ionic:

   Ionic CLI          : 5.4.9 (C:\Users\Kumaro\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.5
   @ionic/app-scripts : 3.2.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 7.1.4
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.0.5, cordova-plugin-ionic-webview 1.1.1, (and 15 other plugins)

Utility:

   cordova-res : not installed
   native-run  : 0.3.0

System:

   Android SDK Tools : 26.1.1 (C:\Program Files\AndroidSDK)
   NodeJS            : v12.13.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.12.0
   OS                : Windows 7

Package.js:


    "name": "Name",
    "version": "1.0.0",
    "author": "Name",
    "homepage": "www.blabla.de",
    "private": true,
    "scripts": 
        "start": "ionic-app-scripts serve",
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "lint": "ionic-app-scripts lint"
    ,
    "dependencies": 
        "@angular/animations": "^7.2.15",
        "@angular/common": "^7.2.15",
        "@angular/compiler": "^7.2.15",
        "@angular/compiler-cli": "^7.2.15",
        "@angular/core": "^7.2.15",
        "@angular/forms": "^7.2.15",
        "@angular/http": "^7.2.15",
        "@angular/platform-browser": "^7.2.15",
        "@angular/platform-browser-dynamic": "^7.2.15",
        "@ionic-native/app-rate": "^5.17.1",
        "@ionic-native/app-version": "^5.17.1",
        "@ionic-native/background-mode": "^5.17.1",
        "@ionic-native/core": "^5.1.0",
        "@ionic-native/device": "^5.17.1",
        "@ionic-native/dialogs": "^5.17.1",
        "@ionic-native/in-app-browser": "^5.17.1",
        "@ionic-native/ionic-webview": "^5.17.1",
        "@ionic-native/keyboard": "^5.17.1",
        "@ionic-native/market": "^5.17.1",
        "@ionic-native/native-storage": "^5.17.1",
        "@ionic-native/screen-orientation": "^5.17.1",
        "@ionic-native/social-sharing": "^5.17.1",
        "@ionic-native/splash-screen": "^5.17.1",
        "@ionic-native/sqlite": "^5.17.1",
        "@ionic-native/status-bar": "^5.17.1",
        "@ionic/storage": "2.2.0",
        "chart.js": "^2.9.3",
        "chartjs-plugin-datalabels": "^0.7.0",
        "cordova": "^9.0.0",
        "cordova-android": "^7.1.4",
        "cordova-plugin-app-version": "^0.1.9",
        "cordova-plugin-apprate": "^1.5.0",
        "cordova-plugin-device": "^2.0.3",
        "cordova-plugin-inappbrowser": "^3.1.0",
        "cordova-plugin-ionic-keyboard": "^2.2.0",
        "cordova-plugin-ionic-webview": "^4.1.3",
        "cordova-plugin-market": "^1.2.0",
        "cordova-plugin-nativestorage": "^2.3.2",
        "cordova-plugin-screen-orientation": "^3.0.2",
        "cordova-plugin-splashscreen": "^5.0.3",
        "cordova-plugin-statusbar": "^2.4.3",
        "cordova-plugin-whitelist": "^1.3.4",
        "cordova-plugin-x-socialsharing": "^5.6.2",
        "cordova-sqlite-storage": "^4.0.0",
        "ionic-angular": "3.9.5",
        "ionicons": "3.0.0",
        "rxjs": "^6.5.3",
        "rxjs-compat": "^6.5.3",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.8.29"
    ,
    "devDependencies": 
        "@ionic/app-scripts": "3.2.2",
        "@ionic/lab": "^2.0.16",
        "cordova-plugin-background-mode": "^0.7.3",
        "cordova-plugin-dialogs": "^2.0.2",
        "cordova-plugin-firebase": "^2.0.5",
        "typescript": "^3.1.1"
    ,
    "description": "An Ionic project",
    "cordova": 
        "plugins": 
            "cordova-plugin-inappbrowser": ,
            "cordova-plugin-device": ,
            "cordova-plugin-splashscreen": ,
            "cordova-plugin-ionic-webview": ,
            "cordova-plugin-ionic-keyboard": ,
            "cordova-plugin-statusbar": ,
            "cordova-plugin-nativestorage": ,
            "cordova-sqlite-storage": ,
            "cordova-plugin-x-socialsharing": ,
            "cordova-plugin-apprate": ,
            "cordova-plugin-market": ,
            "cordova-plugin-screen-orientation": ,
            "cordova-plugin-app-version": ,
            "cordova-plugin-background-mode": ,
            "cordova-plugin-dialogs": ,
            "cordova-plugin-firebase": ,
            "cordova-plugin-whitelist": 
        ,
        "platforms": [
            "android"
        ]
    

希望有人能帮忙:(

【问题讨论】:

这是 Ionic 3 应用吗? 你是对的 【参考方案1】:

首先,您需要在您的问题上设置正确的标签。现在我已经做到了。即Ionic 3

您的更新有误。 Ionic 3 不支持Angular 7RxJS 6 +

您需要关注这个官方应用更新到正确的版本。

官方 Ionic 3 应用程序:https://github.com/ionic-team/ionic-conference-app/blob/v3/package.json#L16

从 Ionic 3.0 迁移到 Ionic 4.0: https://ionicframework.com/docs/building/migration

【讨论】:

抱歉错误!所以我必须降级到旧版本或将我的应用程序迁移到 ionic 4?正确的?但一切都很好,而不是打字稿。所以角度和 rxjs 6 不是问题:) 这取决于你。从 3 迁移到 4 并非易事。您可以查看上面的链接。但未来是 Ionic 4。

以上是关于Ionic Cordova Build prod:找不到模块“。” - 打字稿版本>3的主要内容,如果未能解决你的问题,请参考以下文章

ionic cordova build android --prod 使 JavaScript 堆内存不足

使用ionic cordova build android --release --prod命令打包报错解决方法

Ionic Cordova Build prod:找不到模块“。” - 打字稿版本>3

Ionic V4 - Build Prod “找不到 cordova.js 脚本标签。插件加载可能失败。”

Ionic cordova build android –prod –release 只构建一个调试apk (app-debug.apk)

Ionic 2: - prod文件未编译错误:build prod failed:无法确定类HomePage的模块