接近堆限制的无效标记压缩分配失败 - Windows Angular

2024-01-14

My AngularWindows 10 中的应用程序,使用时抛出错误ng build --prod。这是为ng build.

我的项目使用4json文件在assets文件夹。一个文件大小为 21 MB,另外 3 个文件大小为 4-5 MB。如果我删除 21MB 文件,它就可以正常工作。

PS D:\ProjectPath\Project1> ng build --prod
Option "extractCss" is deprecated: Deprecated since version 11.0. No longer required to disable CSS extraction for HMR.
⠏ Generating browser application bundles (phase: building)...
<--- Last few GCs --->

[17748:00000150A9FB1CE0]   191749 ms: Mark-sweep 2033.1 (2052.3) -> 2032.4 (2053.3) MB, 1579.1 / 0.1 ms  (average mu = 0.135, current mu = 0.011) allocation failure scavenge might not succeed
[17748:00000150A9FB1CE0]   194133 ms: Mark-sweep 2034.3 (2053.3) -> 2032.9 (2053.1) MB, 2361.8 / 0.1 ms  (average mu = 0.063, current mu = 0.009) allocation failure scavenge might not succeed


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 00007FF7D832B3BD]
    1: StubFrame [pc: 00007FF7D82B1861]
Security context: 0x00b2bd4808d1 <JSObject>
    2: __staticCloseRef [00000081B4335C81] [D:\ProjectPath\Project1\node_modules\@angular-devkit\build-angular\node_modules\eslint-scope\lib\scope.js:~293] [pc=0000014C9D9EFFFD](this=0x02d92c6dbc51 <Scope map = 000000A0B9AAA739>,0x02d92c6dcba9 <Reference map = 000000A...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7D7715EBF napi_wrap+114095
 2: 00007FF7D76C0B46 v8::base::CPU::has_sse+66998
 3: 00007FF7D76C1946 v8::base::CPU::has_sse+70582
 4: 00007FF7D7ED6E4E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7D7EBEF21 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF7D7D8B18C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF7D7D963C0 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312
 8: 00007FF7D7D92EE4 v8::internal::Heap::PageFlagsAreConsistent+3204
 9: 00007FF7D7D886E3 v8::internal::Heap::CollectGarbage+1283
10: 00007FF7D7D86D54 v8::internal::Heap::AddRetainedMap+2452
11: 00007FF7D7DA809D v8::internal::Factory::NewFillerObject+61
12: 00007FF7D7B0E1E1 v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1665
13: 00007FF7D832B3BD v8::internal::SetupIsolateDelegate::SetupHeap+546637
14: 00007FF7D82B1861 v8::internal::SetupIsolateDelegate::SetupHeap+48113
15: 0000014C9D9EFFFD

这是我的Angular.json file

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
"Project1": {
  "projectType": "application",
  "schematics": {},
  "root": "",
  "sourceRoot": "src",
  "prefix": "app",
  "architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/Project1",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "tsconfig.app.json",
        "aot": true,
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "src/styles.css"
        ]          
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true,
          "budgets": [
            {
              "type": "initial",
              "maximumWarning": "5mb",
              "maximumError": "10mb"
            },
            {
              "type": "anyComponentStyle",
              "maximumWarning": "6kb",
              "maximumError": "10kb"
            }
          ]
        }
      }
    },
    "serve": {
      "builder": "@angular-devkit/build-angular:dev-server",
      "disableHostCheck": true,
      "options": {
        "browserTarget": "Project1:build"
      },
      "configurations": {
        "fr": { "browserTarget": "qwikCollaborator:build:fr" },
        "en": {"browserTarget": "qwikCollaborator:build:en" } 
        }       
    },
    "extract-i18n": {
      "builder": "@angular-devkit/build-angular:extract-i18n",
      "options": {
        "browserTarget": "Project1:build"
      }
    },
    "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "tsconfig.spec.json",
        "karmaConfig": "karma.conf.js",
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
          "../node_modules/bootstrap/dist/css/bootstrap.min.css",
          "src/styles.css"
        ],
        "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js",              
          "/node_modules/popper.js/dist/umd/popper.min.js"
        ]
      }
    },
    "lint": {
      "builder": "@angular-devkit/build-angular:tslint",
      "options": {
        "tsConfig": [
          "tsconfig.app.json",
          "tsconfig.spec.json",
          "e2e/tsconfig.json",
          "tsconfig.worker.json"
        ],
        "exclude": [
          "**/node_modules/**"
        ]
      }
    },
    "e2e": {
      "builder": "@angular-devkit/build-angular:protractor",
      "options": {
        "protractorConfig": "e2e/protractor.conf.js",
        "devServerTarget": "Project1:serve"
      },
      "configurations": {
        "production": {
          "devServerTarget": "Project1:serve:production"
        }
      }
    }
  }
}
  },
  "defaultProject": "Project1",
  "cli": {
    "analytics": "8062720d-180a-4964-84ea-93f7438a70dd"
  }
}

这是我的package.json file

{
  "name": "project1",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",   
    "build:prod": "node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod --aot",
    "build:": "node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build --aot",
    "start": "ng serve", 
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@amcharts/amcharts4": "^4.10.13",
    "@amcharts/amcharts4-geodata": "^4.1.19",
    "@angular-devkit/build-webpack": "^0.1102.3",
    "@angular/animations": "~11.2.4",
    "@angular/cdk": "~11.1.0",
    "@angular/common": "~11.2.4",
    "@angular/compiler": "~11.2.4",
    "@angular/core": "~11.2.4",
    "@angular/forms": "~11.2.4",
    "@angular/google-maps": "^11.1.0",
    "@angular/localize": "^11.2.4",
    "@angular/material": "^11.1.0",
    "@angular/platform-browser": "~11.2.4",
    "@angular/platform-browser-dynamic": "~11.2.4",
    "@angular/router": "~11.2.4",
    "@ng-bootstrap/ng-bootstrap": "^9.0.0",
    "bluebird": "^3.7.2",
    "bootstrap": "^4.6.0",
    "bootstrap4-toggle": "^3.6.1",
    "chart.js": "^2.9.4",
    "chartjs-plugin-datalabels": "^0.7.0",
    "hammerjs": "^2.0.8",
    "increase-memory-limit": "^1.0.7",
    "jquery": "^3.6.0",
    "main.js": "0.0.1",
    "mdbootstrap": "^4.19.2",
    "moment": "^2.29.1",
    "ngx-pagination": "^5.0.0",
    "popper.js": "^1.16.1",
    "rxjs": "~6.6.3",
    "stream": "0.0.2",
    "time-ago-pipe": "^1.3.2",
    "timers": "^0.1.1",
    "tslib": "^2.1.0",
    "webpack": "^4.36.0",
    "xml-js": "^1.6.11",
    "zone.js": "~0.11.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.1102.3",
    "@angular/cli": "^11.2.3",
    "@angular/compiler-cli": "^11.2.4",
    "@angular/language-service": "~11.2.4",
    "@types/jasmine": "~3.6.3",
    "@types/jasminewd2": "~2.0.8",
    "@types/node": "~14.14.22",
    "@types/xml2js": "^0.4.7",
    "codelyzer": "^6.0.1",
    "cross-env": "^7.0.3",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~6.0.0",
    "karma": "~6.0.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "protractor": "~7.0.0",
    "ts-node": "~9.1.1",
    "tslint": "~6.1.3",
    "typescript": "^4.1.3"
  }
}

我也添加了这个解决方案Angular.json 接近堆限制的无效标记压缩分配失败 - JavaScript 堆内存不足 https://stackoverflow.com/questions/59965966/ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-ou也尝试过这个https://www.npmjs.com/package/increase-memory-limit https://www.npmjs.com/package/increase-memory-limit我已经执行了setx NODE_OPTIONS --max_old_space_size=10240 in cmd, 还是行不通。

角度 CLI:10.0.5 节点:12.18.3 操作系统:win32 x64

我怎样才能解决这个问题?


我通过运行下面的命令修复了这个问题Visual Studio Code终端。

 node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod

代替ng build --prod我已经使用了上面的命令。

Script tag in package.json

  "scripts": {
    "ng": "ng",   
    "build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod",
    "build:": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build",
    "start": "ng serve", 
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

接近堆限制的无效标记压缩分配失败 - Windows Angular 的相关文章

  • 在 MongoDB 中查找具有字符串 ID 数组的文档

    我有一个 id 字符串数组 我想将其与 find 函数一起使用 db companies find id in arr arr看起来像这样 563a2c60b511b7ff2c61e938 563a2c60b511b7ff2c61e8b7
  • 为什么 jQuery 点击事件会多次触发

    我这里有这个示例代码http jsfiddle net DBBUL 10 http jsfiddle net DBBUL 10 document ready function creategene click function confir
  • Typescript 函数返回类型取决于参数的数量或类型

    假设我有一个函数 它应该根据参数的数量和类型返回不同的类型 我该如何在 TypeScript 中描述这一点 function foo t number string function foo t number s string boolea
  • 在 BIRT 中输入参数后更新数据集查询

    在 BIRT 报告设计中传递参数后 如何更改或更新数据集的查询 详细说明 我有一个如下所示的查询 WHERE 该参数标记可以保存不同的值 在用户输入参数后 它看起来像这样 例如 WHERE column name 1 or WHERE co
  • 未捕获的引用错误:myFunction 未定义[重复]

    这个问题在这里已经有答案了 这到底是怎么回事 http jsfiddle net sVT54 http jsfiddle net sVT54
  • 响应式网格布局框架[关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 使react-leaflet能够离线使用

    我一直在使用反应传单 https github com PaulLeCam react leaflet图书馆 到目前为止运作良好 现在我希望网站预加载尽可能多的图块 以便网络应用程序 也是 PWA 可以在没有互联网的情况下使用 我找到了一些
  • KeyboardEvent.keyCode 已弃用。这在实践中意味着什么?

    根据 MDN 我们绝对应该not正在使用 keyCode财产 它已被弃用 https developer mozilla org en US docs Web API KeyboardEvent keyCode https develope
  • 在 Angular 材质表上调用 renderRows()

    我试图在更新表中使用的数据后刷新我的 Angular 表 文档说 您可以通过调用其 renderRows 方法来触发对表的渲染行的更新 但它不像普通的子组件 我可以使用 ViewChild MatSort sort MatSort 因为我不
  • 访问 TypeScript 数组的最后一个元素

    TypeScript 中有访问数组最后一个元素的符号吗 在 Ruby 中我可以说 array 1 有类似的东西吗 您可以通过索引访问数组元素 数组中最后一个元素的索引将是数组的长度 1 因为索引是从零开始的 这应该有效 var items
  • jQuery 选择器:为什么 $("#id").find("p") 比 $("#id p") 更快

    该页面的作者 http 24ways org 2011 your jquery now with less suck http 24ways org 2011 your jquery now with less suck断言 jQuery
  • 角度 2 中的动态 styleUrls?

    是否可以将样式表的 url 动态注入到组件中 就像是 styleUrls stylesheet1 css this additionalUrls 或者 一厢情愿并注意这只是假代码 export class MyComponent imple
  • 使用 jquery 将字符串数组转换为整数

    我正在尝试将 jquery 中的字符串数组转换为整数数组 这是我的尝试 var cdata data values split each cdata function i l l parseInt l 我认为在这种情况下你不需要使用 Jqu
  • 如何在网页上实现文件上传进度条?

    当用户将文件上传到我的网络应用程序时 我想显示比动画 gif 更有意义的内容 我还有哪些可能性 编辑 我正在使用 Net 但我不介意是否有人向我展示与平台无关的版本 如果您对这一切在客户端通常如何工作感兴趣 就是这样 所有解决方案都通过 J
  • 有关于 PHP 中的 V8JS 的文档吗?

    有没有关于V8JS的文档 我是否只需要标准 PHP 或一些扩展即可使用 V8JS 我将非常感谢有关 PHP 中的 V8JS 的任何信息 要求 PHP 5 3 3 和 V8 库和标头安装在正确的路径中 Install http www php
  • window.showModalDialog 的等效跨浏览器解决方案是什么?

    window showModalDialog 的等效跨浏览器解决方案有哪些 showModalDialog 在 IE 和 FF 3 中引入 我个人认为没有 但是有很多 UI 工具包提供了这样的功能 例如jQuery UI http jque
  • React Native - 跨屏幕传递数据

    我遇到了一些麻烦react native应用程序 我不知道如何跨屏幕传递数据 我意识到还有其他类似的问题在 SO 上得到了回答 但是这些解决方案对我来说不起作用 我正在使用StackNavigator 这是我的设置App js file e
  • Typescript:如何定义生成可调用实例的类

    我目前正在将 JS 类转换为 TypeScript 该类扩展自 NPM 模块节点可调用实例 https www npmjs com package callable instance 这使得它在内部成为 Function 的子类 类的实例可
  • Express.js Passport认证自动失败跳过策略

    UPDATE 我已将代码从护照本地注册内部移至单独的处理程序 并且运行良好 问题在于 Passport 和本地注册的使用 但我不知道为什么 我使用 Node js Express Passport 进行身份验证和注册设置 这是以前使用过的标
  • 如何调试 Gulp 任务?

    如何调试我的中定义的 gulp 任务gulpfile js使用诸如 Google Chrome 调试器之类的调试器逐行单步执行任务的代码 对于 Node js 6 3 版本 您可以使用 inspect flag https nodejs o

随机推荐