javascript - 为 Android 构建 Ionic 时出现 "CALL_AND_RETRY_LAST Allocation failed"错误

标签 javascript angularjs cordova ionic-framework ionic3

我正在使用 Ionic 为 Android 构建,但我总是收到此错误:

ionic error

我从 ionic info 那里得到了这个:

ionic info

别搞错了,我已经浏览了整个互联网寻找解决方案,但我没有成功。
我已经看到并阅读了以下内容:

我还观察到与其他人相比,我有这个独特的错误:

Security context: 000001F502E3FA99 <JS Object>     
    1: createLiteral [..]    
    2: typeToTypeNodeHelper(aka typeToTypeNodeHelper) [..]

我已经在这个问题上停留了 2 天多了,我真的需要这方面的帮助和指导。

这是我的 package.json 内容:

{
    "name": "project",
    "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.2.10",
        "@angular/compiler": "5.2.10",
        "@angular/compiler-cli": "5.2.10",
        "@angular/core": "5.2.10",
        "@angular/forms": "5.2.10",
        "@angular/http": "5.2.10",
        "@angular/platform-browser": "5.2.10",
        "@angular/platform-browser-dynamic": "5.2.10",
        "@ionic-native/camera": "^4.5.2",
        "@ionic-native/core": "4.4.0",
        "@ionic-native/file": "^4.7.0",
        "@ionic-native/file-chooser": "^4.7.0",
        "@ionic-native/file-path": "^4.7.0",
        "@ionic-native/geolocation": "^4.7.0",
        "@ionic-native/onesignal": "^4.5.2",
        "@ionic-native/splash-screen": "4.4.0",
        "@ionic-native/status-bar": "4.4.0",
        "@ionic-native/twitter-connect": "^4.5.2",
        "@ionic/storage": "2.1.3",
        "angularfire2": "^5.0.0-rc.6",
        "cordova-android": "^7.0.0",
        "cordova-browser": "~5.0.3",
        "cordova-ios": "4.5.4",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-device": "^1.1.7",
        "cordova-plugin-file": "^6.0.1",
        "cordova-plugin-filechooser": "^1.0.1",
        "cordova-plugin-filepath": "^1.3.0",
        "cordova-plugin-geolocation": "^4.0.1",
        "cordova-plugin-inappbrowser": "^2.0.2",
        "cordova-plugin-ionic-webview": "^1.2.0",
        "cordova-plugin-splashscreen": "^4.1.0",
        "cordova-plugin-statusbar": "^2.4.2",
        "cordova-plugin-whitelist": "^1.3.3",
        "firebase": "^4.12.1",
        "ionic-angular": "3.9.2",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "jssha": "^1.6.2",
        "moment": "^2.20.1",
        "onesignal-cordova-plugin": "^2.2.5",
        "rxjs": "5.5.2",
        "sw-toolbox": "3.6.0",
        "twitter-connect-plugin": "git+https://github.com/chroa/twitter-connect-plugin.git",
        "zone.js": "0.8.18"
    },
    "devDependencies": {
        "@angular/cli": "^1.7.3",
        "@angular-devkit/build-optimizer": "^0.5.7",
        "@ionic/app-scripts": "^3.1.8",
        "@types/jssha": "0.0.29",
        "typescript": "^2.6.2"
    },
    "description": "An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-inappbrowser": {},
            "cordova-plugin-device": {},
            "cordova-plugin-ionic-webview": {},
            "cordova-plugin-splashscreen": {},
            "ionic-plugin-keyboard": {},
            "cordova-plugin-filechooser": {},
            "cordova-plugin-camera": {
                "CAMERA_USAGE_DESCRIPTION": " ",
                "PHOTOLIBRARY_USAGE_DESCRIPTION": " "
            },
            "twitter-connect-plugin": {
                "FABRIC_KEY": "XXXXXXXXXX",
                "TWITTER_KEY": "YYYYYYYYY",
                "TWITTER_SECRET": "ZZZZZZZZZZZZZZZ"
            },
            "cordova-plugin-statusbar": {},
            "cordova-plugin-filepath": {},
            "cordova-plugin-file": {},
            "cordova-plugin-geolocation": {}
        },
        "platforms": [
            "ios",
            "browser",
            "android"
        ]
    },
    "main": "index.js",
    "license": "ISC"
}

编辑: 我按照@Suraj Rao 的建议更新了我的 npm,我的当前版本是 6.0.0,然后我再次尝试构建,我得到了这个 new related error

最佳答案

您可以尝试这些可能对您有帮助的步骤!

首先尝试 npm install 并遵循以下任一方法...

  1. 将其添加到 package.json 脚本中

    "ionic:build": "node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",

  2. 运行命令:

    npm run ionic:build --prod

  3. 运行命令:

    cordova 构建 android --release cordova 构建 ios --release

或者

修改:

node_modules/.bin/ionic-app-scripts.cmd

通过添加:

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node --max_old_space_size=4096  "%~dp0\..\@ionic\app-scripts\bin\ionic-app-scripts.js" %*
)

然后运行ionic build android --prod

来源Click here!

更新:

我不确定到底出了什么问题,但我可以理解有大量文件或内存使用量超出了限制。

试试这个,

节点 --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192 --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192 --prod --aot

希望对你有帮助!

关于javascript - 为 Android 构建 Ionic 时出现 "CALL_AND_RETRY_LAST Allocation failed"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50014452/

相关文章:

javascript - 如何保护 HTML5+PhoneGap 移动应用程序中的数据?

android - 适用于 cordova 2.3.0 android 的 ExtractZipFile

JavaScript 对数组中已运行的项目进行计数

javascript - AngularJS:按数字范围重复和过滤

javascript - 如何使用 --outDir TypeScript 编译器选项

javascript - AngularJS 赋值后变量未定义

asp.net - Web api 和 Angularjs 身份验证失败

ios - 使用Cordova平台添加ios时出现错误

javascript - fa-spin 在启动后停止并重新加载页面

javascript - 如何检查一个点相对于其位置和路线是否位于另一个点的后面?