使用 Azure DevOps 的 Angular 7 中的 JavaScript 堆内存不足 [英] JavaScript heap out of memory in Angular 7 using Azure DevOps

查看:15
本文介绍了使用 Azure DevOps 的 Angular 7 中的 JavaScript 堆内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Angular 7.1 升级后遇到致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足.之前的 6.1 版本运行良好.

I am getting FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory after Angular 7.1 upgrade. The previous version 6.1 was working perfectly fine.

我仅在运行 ng build --prod 命令时在 Azure DevOps 中遇到错误.它在本地构建得非常好.

I get the error only in Azure DevOps while running ng build --prod command. It builds perfectly fine in local.

以下是详细日志.知道为什么我会收到此错误吗?

Below are the detail logs. Any idea why I am getting this error?

2018-11-22T06:40:36.2804965Z ##[section]Starting: npm build
2018-11-22T06:40:36.2809301Z ==============================================================================
2018-11-22T06:40:36.2809365Z Task         : npm
2018-11-22T06:40:36.2809456Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
2018-11-22T06:40:36.2809496Z Version      : 1.0.27
2018-11-22T06:40:36.2809531Z Author       : Microsoft Corporation
2018-11-22T06:40:36.2809612Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613746)
2018-11-22T06:40:36.2809648Z ==============================================================================
2018-11-22T06:40:36.7158800Z SYSTEMVSSCONNECTION exists true
2018-11-22T06:40:36.8019327Z SYSTEMVSSCONNECTION exists true
2018-11-22T06:40:36.8872807Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" --version"
2018-11-22T06:40:37.5174051Z 6.4.1
2018-11-22T06:40:38.9461529Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" config list"
2018-11-22T06:40:39.5927698Z ; cli configs
2018-11-22T06:40:39.5928553Z metrics-registry = "https://registry.npmjs.org/"
2018-11-22T06:40:39.5929006Z scope = ""
2018-11-22T06:40:39.5929176Z user-agent = "npm/6.4.1 node/v8.12.0 win32 x64"
2018-11-22T06:40:39.5929292Z 
2018-11-22T06:40:39.5929425Z ; environment configs
2018-11-22T06:40:39.5929577Z cache = "C:\\npm\\cache"
2018-11-22T06:40:39.5929756Z prefix = "C:\\npm\\prefix"
2018-11-22T06:40:39.5929899Z userconfig = "D:\\a\\1\\npm\\17729.npmrc"
2018-11-22T06:40:39.5930010Z 
2018-11-22T06:40:39.5930159Z ; builtin config undefined
2018-11-22T06:40:39.5930270Z 
2018-11-22T06:40:39.5930403Z ; node bin location = C:\Program Files\nodejs\node.exe
2018-11-22T06:40:39.5930552Z ; cwd = D:\a\1\s\client
2018-11-22T06:40:39.5930686Z ; HOME = C:\Users\VssAdministrator
2018-11-22T06:40:39.5930817Z ; "npm config ls -l" to show all defaults.
2018-11-22T06:40:39.5930928Z 
2018-11-22T06:40:39.5931996Z [command]C:\Windows\system32\cmd.exe /D /S /C ""C:\Program Files\nodejs\npm.cmd" run build"
2018-11-22T07:33:30.0639548Z FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
2018-11-22T07:33:30.0640628Z  1: node_module_register
2018-11-22T07:33:30.0640676Z  2: v8::internal::FatalProcessOutOfMemory
2018-11-22T07:33:30.0640710Z  3: v8::internal::FatalProcessOutOfMemory
2018-11-22T07:33:30.0640744Z  4: v8::internal::Factory::NewRawTwoByteString
2018-11-22T07:33:30.0640825Z  5: v8::internal::Smi::SmiPrint
2018-11-22T07:33:30.0640861Z  6: v8::internal::StackGuard::HandleInterrupts
2018-11-22T07:33:30.0640894Z  7: v8::internal::AsmJsScanner::IsNumberStart
2018-11-22T07:33:30.0640967Z  8: 000002B496D043C1
2018-11-22T07:33:30.0641001Z npm ERR! code ELIFECYCLE
2018-11-22T07:33:30.0641034Z npm ERR! errno 3
2018-11-22T07:33:30.0641210Z npm ERR! iceux@0.0.1 build: `ng build --prod`
2018-11-22T07:33:30.0641470Z npm ERR! Exit status 3
2018-11-22T07:33:30.0641528Z npm ERR! 
2018-11-22T07:33:30.0641569Z npm ERR! Failed at the iceux@0.0.1 build script.
2018-11-22T07:33:30.0641615Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-11-22T07:33:30.0641703Z 
2018-11-22T07:33:30.0641749Z npm ERR! A complete log of this run can be found in:
2018-11-22T07:33:30.0641795Z npm ERR!     C:\npm\cache\_logs\2018-11-22T07_33_30_018Z-debug.log
2018-11-22T07:33:30.0641823Z 
2018-11-22T07:33:30.0641910Z > iceux@0.0.1 build D:\a\1\s\client
2018-11-22T07:33:30.0641951Z > ng build --prod
2018-11-22T07:33:30.0641978Z 
2018-11-22T07:33:30.1213960Z Found npm debug log, make sure the path matches with the one in npm's output: C:\npm\cache\_logs\2018-11-22T07_33_30_018Z-debug.log
2018-11-22T07:33:30.1214046Z 0 info it worked if it ends with ok
2018-11-22T07:33:30.1214104Z 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
2018-11-22T07:33:30.1214189Z 1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
2018-11-22T07:33:30.1215590Z 1 verbose cli   'run',
2018-11-22T07:33:30.1215635Z 1 verbose cli   'build' ]
2018-11-22T07:33:30.1215667Z 2 info using npm@6.4.1
2018-11-22T07:33:30.1215727Z 3 info using node@v8.12.0
2018-11-22T07:33:30.1215759Z 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
2018-11-22T07:33:30.1215801Z 5 info lifecycle iceux@0.0.1~prebuild: iceux@0.0.1
2018-11-22T07:33:30.1215835Z 6 info lifecycle iceux@0.0.1~build: iceux@0.0.1
2018-11-22T07:33:30.1216048Z 7 verbose lifecycle iceux@0.0.1~build: unsafe-perm in lifecycle true
2018-11-22T07:33:30.1216372Z 8 verbose lifecycle iceux@0.0.1~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\a\1\s\client\node_modules\.bin;C:\agents\2.141.1\externals\git\cmd;C:\tools\mingw64\bin;C:\Program Files\dotnet;C:\mysql-5.7.21-winx64\bin;C:\Program Files\Java\jdk1.8.0_181\bin;C:\npm\prefix;C:\hostedtoolcache\windows\Ruby\2.5.0\x64\bin;C:\Go1.11\bin;C:\Program Files\Git\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Scripts;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\ProgramData\Chocolatey\bin;C:\Program Files\Docker;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\Git\cmd;C:\Program Files (x86)\Subversion\bin;C:\Program Files\nodejs\;C:\Program Files\CMake\bin;C:\Users\VssAdministrator\AppData\Local\Microsoft\WindowsApps
2018-11-22T07:33:30.1216877Z 9 verbose lifecycle iceux@0.0.1~build: CWD: D:\a\1\s\client
2018-11-22T07:33:30.1216979Z 10 silly lifecycle iceux@0.0.1~build: Args: [ '/d /s /c', 'ng build --prod' ]
2018-11-22T07:33:30.1217028Z 11 silly lifecycle iceux@0.0.1~build: Returned: code: 3  signal: null
2018-11-22T07:33:30.1217062Z 12 info lifecycle iceux@0.0.1~build: Failed to exec build script
2018-11-22T07:33:30.1217103Z 13 verbose stack Error: iceux@0.0.1 build: `ng build --prod`
2018-11-22T07:33:30.1217135Z 13 verbose stack Exit status 3
2018-11-22T07:33:30.1217173Z 13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
2018-11-22T07:33:30.1217215Z 13 verbose stack     at emitTwo (events.js:126:13)
2018-11-22T07:33:30.1217250Z 13 verbose stack     at EventEmitter.emit (events.js:214:7)
2018-11-22T07:33:30.1217287Z 13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
2018-11-22T07:33:30.1217332Z 13 verbose stack     at emitTwo (events.js:126:13)
2018-11-22T07:33:30.1217381Z 13 verbose stack     at ChildProcess.emit (events.js:214:7)
2018-11-22T07:33:30.1217413Z 13 verbose stack     at maybeClose (internal/child_process.js:915:16)
2018-11-22T07:33:30.1217448Z 13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
2018-11-22T07:33:30.1217488Z 14 verbose pkgid iceux@0.0.1
2018-11-22T07:33:30.1217521Z 15 verbose cwd D:\a\1\s\client
2018-11-22T07:33:30.1217551Z 16 verbose Windows_NT 10.0.14393
2018-11-22T07:33:30.1217588Z 17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
2018-11-22T07:33:30.1217629Z 18 verbose node v8.12.0
2018-11-22T07:33:30.1217659Z 19 verbose npm  v6.4.1
2018-11-22T07:33:30.1217690Z 20 error code ELIFECYCLE
2018-11-22T07:33:30.1217727Z 21 error errno 3
2018-11-22T07:33:30.1218070Z 22 error iceux@0.0.1 build: `ng build --prod`
2018-11-22T07:33:30.1218102Z 22 error Exit status 3
2018-11-22T07:33:30.1218134Z 23 error Failed at the iceux@0.0.1 build script.
2018-11-22T07:33:30.1218187Z 23 error This is probably not a problem with npm. There is likely additional logging output above.
2018-11-22T07:33:30.1218220Z 24 verbose exit [ 3, true ]
2018-11-22T07:33:30.1218241Z 
2018-11-22T07:33:30.1286371Z ##[error]Error: Npm failed with return code: 3
2018-11-22T07:33:30.1298403Z ##[section]Finishing: npm build

Package.json

Package.json

{
  "name": "iceux",
  "version": "0.0.1",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --ssl true",
    "build": "ng build --prod",
    "test": "ng test",
    "testauto": "ng test --watch=false --browsers=ChromeHeadless --code-coverage",
    "lint": "ng lint iceux --format stylish",
    "pree2e": "webdriver-manager update",
    "e2e": "ng e2e --dev-server-target=iceux:serve",
    "e2e:fast": "ng e2e --configuration=fast",
    "e2e:azure": "ng e2e --configuration=azure",
    "e2e:perf": "ng e2e --configuration=perf"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "7.1.0",
    "@angular/common": "7.1.0",
    "@angular/compiler": "7.1.0",
    "@angular/core": "7.1.0",
    "@angular/forms": "7.1.0",
    "@angular/http": "7.1.0",
    "@angular/platform-browser": "7.1.0",
    "@angular/platform-browser-dynamic": "7.1.0",
    "@angular/router": "7.1.0",
    "@epicor/kinetic": "^2.1.0-alpha.20",
    "@ngrx/effects": "^6.1.0",
    "@ngrx/entity": "^6.1.0",
    "@ngrx/store": "^6.1.0",
    "@ngrx/store-devtools": "^6.1.0",
    "@progress/kendo-angular-inputs": "^3.1.3",
    "@progress/kendo-angular-intl": "^1.4.1",
    "@progress/kendo-angular-l10n": "^1.2.0",
    "@progress/kendo-angular-layout": "^3.1.1",
    "@progress/kendo-angular-menu": "^1.0.0",
    "@progress/kendo-angular-toolbar": "^0.2.1",
    "@progress/kendo-angular-treeview": "^2.2.0",
    "@progress/kendo-theme-default": "latest",
    "@telerik/kendo-intl": "^1.4.4",
    "angular2-query-builder": "^0.3.3",
    "core-js": "^2.5.5",
    "json-logic-js": "^1.2.2",
    "lodash": "^4.17.10",
    "logrocket": "^0.6.17",
    "rxjs": "^6.3.3",
    "rxjs-compat": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.10.0",
    "@angular/cli": "7.0.6",
    "@angular/compiler-cli": "7.1.0",
    "@angular/language-service": "7.1.0",
    "@ngrx/schematics": "^6.1.0",
    "@types/jasmine": "^2.8.7",
    "@types/jasminewd2": "~2.0.2",
    "@types/lodash": "^4.14.108",
    "@types/node": "~8.9.4",
    "codelyzer": "^4.3.0",
    "jasmine-core": "~2.99.1",
    "jasmine-reporters": "^2.3.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.1",
    "rxjs-tslint": "^0.1.5",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "~3.1.6"
  }
}

推荐答案

尝试像这样运行 prod build:

Try to run prod build like this:

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

我昨天遇到了同样的错误,这有助于我避免它.

I have the same error yesterday and it's helps me to avoid it.

这篇关于使用 Azure DevOps 的 Angular 7 中的 JavaScript 堆内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆