gpt4 book ai didi

javascript - Angular 5.2 : Getting error while building application using VSTS build server : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

转载 作者:行者123 更新时间:2023-12-03 00:27:42 25 4
gpt4 key购买 nike

构建突然开始失败,并出现以下错误:

2019-01-03T12:57:22.2223175Z EXEC : FATAL error : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
error MSB3073: The command "node node_modules/webpack/bin/webpack.js --env.prod" exited with code 3.

我已经尝试了所有可用的解决方案,例如:
1)更新Windows的虚拟内存
2)更新NPM版本和Node版本
3)还尝试添加命令来增加 --max_old_space_size

在发布 Angular APP 时仍然面临同样的问题。它在本地工作,但在发布时在构建服务器上失败在本地出现以下错误:

    <--- Last few GCs --->

[2212:000002BC74FB20D0] 152613 ms: Mark-sweep 1411.4 (1466.9) -> 1411.4 (1466.9) MB, 2117.6 / 0.0 ms last resort GC in old space requested


<--- JS stacktrace --->

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

Security context: 0000032354625EE1 <JSObject>
1: bindContainer [node_modules\typescript\lib\typescript.js:~22960] [pc=000003AD4C9DBFB9](this=000000063100BE21 <JSGlobal Object>,node=000001B7FE6A7E61 <NodeObject map = 0000020A3EA721A1>,containerFlags=45)
2: visitNodeArray [node_modules\typescript\lib\typescript.js:~15947] [pc=000003AD4C9A32A5](this=000000063100BE21 <JSGloba...

最佳答案

当为执行应用程序分配的内存小于运行应用程序所需的内存时,会出现此错误,默认情况下Node会分配一定大小的内存。

您可以为每个更改 package.json 的构建增加此大小,因此即使在本地或在服务器中,应用程序也会以理想的内存分配大小准备发布。

"build": "node --max-old-space-size=4096 ./node_modules/@angular/cli/bin/ng build --prod",

另一个选项是在 npm 文件夹中,编辑 ng.cmd 以始终增加内存大小。

@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node --max_old_space_size=8192 "%~dp0\..\@angular\cli\bin\ng" %*
)

一个不太优雅的解决方案是使用处理此问题的依赖项。从项目的根位置运行:

npm install -g increase-memory-limit
increase-memory-limit

在服务器中,您需要在发布之前为这些步骤创建一个脚本。有关该包的更多详细信息,请参见此处:https://www.npmjs.com/package/increase-memory-limit

关于javascript - Angular 5.2 : Getting error while building application using VSTS build server : CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54022864/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com