700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 如何解决angular项目启动 报内存溢出

如何解决angular项目启动 报内存溢出

时间:2024-04-07 05:00:57

相关推荐

如何解决angular项目启动 报内存溢出

问题描述:

在使用angular启动项目时,有时候会报内存溢出的错误,导致项目启动失败。

报错信息如下:

<--- JS stacktrace --->==== JS stack trace =========================================0: ExitFrame [pc: 0000002919A5C5C1]Security context: 0x02b9c119e6e9 <JSObject>1: _send [0000016FEC87BBF1] [internal/child_process.js:736] [bytecode=0000016FEC878FD9 offset=660](this=0x0013a6e4b2b9 <ChildProcess map = 000003A8411F6819>,message=0x029b3af56a39 <Object map = 000003A8411F7371>,handle=0x029057e026f1 <undefined>,options=0x029b3af56ad9 <Object map = 000003A8411F8971>,callback=0x029057e026f1 <undefined>)2: send [000...FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

启动失败的原因:nodejs 默认限制了最大可使用的内存大小。

解决办法:

在项目的node-module模块node_modules.bin模块下, 找到ng.cmd和ngc.cmd

通过配置–max_old_space_size属性,修改最大可使用的内存大小。

ng.cmd文件:

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

ngc.cmd文件:

@IF EXIST "%~dp0\node.exe" ("%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\._@angular_compiler-cli@4.0.1@@angular\compiler-cli\src\main.js" %*) ELSE (@SETLOCAL@SET PATHEXT=%PATHEXT:;.JS;=;%node --max_old_space_size=8192 "%~dp0\..\._@angular_compiler-cli@4.0.1@@angular\compiler-cli\src\main.js" %*)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。