Angular 2 AoT Heep 错误 [英] Angular 2 AoT Heep Errors
问题描述
AoT 编译导致JavaScript heap out of memory"错误
AoT compilation resulting in " JavaScript heap out of memory" error
我正在尝试按照 angular.io 上提供的 AoT 指南来编译我的项目
I am trying to compile my project by following the AoT guide available on angular.io
下面是我的 aot 类型脚本配置文件
Below is my typesccript configuration file for aot
<代码>{编译器选项":{emitDecoratorMetadata":真,"experimentalDecorators": 真,模块":es2015","moduleResolution": "节点",noImplicitAny":假,"suppressImplicitAnyIndexErrors": true,noEmitOnError":真,"removeComments": 真,源地图":假,"目标": "es5","outDir": "../content/app/"},角度编译器选项":{"genDir": "aot",skipMetadataEmit":真},排除": [节点模块","打字/主要",打字/main.d.ts"]}
我正在使用以下命令进行编译:
I am compiling using below command:
D:\MyProject\node_modules\.bin>ngc -p ../../app/tsconfig-aot.json
编译需要时间并最终出现以下错误:
It takes times in compilation and ends up with below errors:
<--- Last few GCs --->
215225 ms: Mark-sweep 1327.9 (1434.3) -> 1316.1 (1434.3) MB, 1233.5 / 0.0 ms [allocation failure] [GC in old space requested].
216639 ms: Mark-sweep 1316.1 (1434.3) -> 1316.1 (1434.3) MB, 1413.5 / 0.0 ms [allocation failure] [GC in old space requested].
217985 ms: Mark-sweep 1316.1 (1434.3) -> 1320.4 (1403.3) MB, 1346.7 / 0.0 ms [last resort gc].
219337 ms: Mark-sweep 1320.4 (1403.3) -> 1324.6 (1403.3) MB, 1351.5 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 00000023CEBCFB61 <JS Object>
1: copyProperties [D:\MyProject\node_modules\typescript\lib\typescript.js:1462] [pc=000001870A3EC95C] (this=000000AAE12C6A41 <an Object with map 00000279F6259FA1>,source=000002E70921E389 <an Object with map 00000279F62D8539>,target=000002ED3C5C7691 <an Object with map 000000D6F40CD1C9>)
2: objectTypeRelatedTo [D:\MyProject\node_modules\typescript\lib\typescript.js:...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
D:\MyProject\node_modules\.bin>
我要编译的项目有 467 个文件.
The project I am trying to compile has 467 files.
推荐答案
如果您在尝试接受的答案后仍然在 Windows 上遇到此问题,您可以使用以下解决方法 (@angular/compiler-cli 2.2.1):>
If you still have this issue on windows after trying the accepted answer you can use the following workaround (@angular/compiler-cli 2.2.1):
node --max-old-space-size=8192 node_modules/@angular/compiler-cli/src/main.js -p tsconfig-aot.json
这可能不适用于未来的更新,因为如果您解释 ./node_modules/.bin/ngc,上述所有内容都是指向实际的 js 文件.
This might not work with future updates as all the above does is point to the actual js file if you interpret ./node_modules/.bin/ngc.
这篇关于Angular 2 AoT Heep 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!