我正在以下环境中开发angular-cli应用程序:
OS: Windows 10
Nodejs: 6.9.2
npm: 3.3.10
angular-cli: 1.0.0-beta.25.5
当我在执行ng test --watch
时更改代码时,每次出现以下错误:
<--- Last few GCs --->
541882 ms: Mark-sweep 1369.1 (1393.2) -> 1369.0 (1394.2) MB, 233.9 / 0.1 ms [allocation failure] [GC in old space requested].
542130 ms: Mark-sweep 1369.0 (1394.2) -> 1369.0 (1395.2) MB, 248.3 / 0.0 ms [allocation failure] [GC in old space requested].
542384 ms: Mark-sweep 1369.0 (1395.2) -> 1369.0 (1394.2) MB, 253.6 / 0.0 ms [last resort gc].
542632 ms: Mark-sweep 1369.0 (1394.2) -> 1369.0 (1394.2) MB, 248.9 / 0.0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 000001EE28FCFB61 <JS Object>
1: toString [buffer.js:~487] [pc=000002AB3E7A5497] (this=000001E2642F0C41 <an Uint8Array with map 0000001D5B706569>)
2: /* anonymous */ [C:\dev\{my_project}\node_modules\karma\lib\preprocessor.js:122] [pc=000002AB3E7A9B68] (this=000001EE28FE6659 <JS Global Object>,err=000001EE28F04201 <null>,thisFileIsBinary=000001E...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
node --max_old_space_size=4096 node_modules/angular-cli/bin/ng test --watch
解决了这个问题,但理想情况下我只想使用ng test
命令。除此之外,我尝试将项目迁移到angular-cli@1.0.0
和ng test --max_old_space_size=4096
,但它们无效。
有没有办法只使用ng test
命令修复此问题?
提前致谢。