简体   繁体   中英

Angular CLI ng test Errors

I've got TypeScript 2.1 and install the latest Angular CLI. ng e2e will run, but ng test gives the error

<--- Last few GCs --->

   52499 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1045.6 / 0 ms [allocation failure] [GC in old space requested].
   53547 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1048.7 / 0 ms [allocation failure] [GC in old space requested].
   54622 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1074.2 / 0 ms [last resort gc].
   55683 ms: Mark-sweep 1366.6 (1434.2) -> 1366.6 (1434.2) MB, 1061.9 / 0 ms [last resort gc].


<--- JS stacktrace --->

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

Security context: 000000C0003C9E79 <JS Object>
    1: scanNumber [...typescript\lib\typescript.js:~4482] [pc=000002B5ABFA230E] (this=000000C0003E4649 <JS Global Object>)
    2: scan [..\typescript\lib\typescript.js:~4820] [pc=000002B5ABF09246] (this=00000348EBB58831 <an Object with map 000000BFCA178B91>)
    3: parseDelimitedList [\...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

I tried deleting node_modules and ran npm i again and no luck. This is with no edits to any generated test files.

Definitely don't delete node_modules. You'll need to cd back into your project's home directory and run npm install to reinstall all of your node packages.

Instead it's important that you understand the difference between memory and storage. Memory has to do with your RAM (data in use on currently used applications) and storage has to do with your hard drive. This suggests to me that you have too many things running in your browser, or you are somehow creating a huge amount in your application.

Try to close your browsers and reopen. if that doesn't work then you'll need to take a look at your code for any logic that that is endless, like a for loop that never ends. try commenting out sections that you suspect and see if ng test works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM