简体   繁体   中英

npm runs “JavaScript heap out of memory” (nearly) every time

I got problems with running npm into FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory . Since I installed node.js&npm on my new PC it doesnt worked.

The only npm command which works is npm -v others run into out of memory.

System-Information:

  • Win10 (64 bit; 16GB Ram (normaly ~6GB free RAM); i7-7820HQ)
  • node -v => v7.4.0
  • npm -v => 4.1.2
  • $path to /c/NodeJS/ (node.js root folder)

What I tried:

  • fresh installation of node.js&npm in serveral versions (all got nealy the same exception)
  • checked ~/.npm & ~/npm_cache (both doesn't exist)
  • run npm via node --max_old_space_size=8000 /usr/bin/npm [command] but results in different exception (exception "Z") ( https://stackoverflow.com/a/40939496 )

What I wonder:

  • Ram rises to ~1.4-1.5 GB Ram with CPU usage of ~40%
  • then CPU usage dropped to ~12-17% (I think GCs)
  • until then no single log/exception output in gitbash/cmd even with -ddd (verbose)
  • after Strg+C interrupt and annother ~2Min the following Exception

Exception:

$ npm help -ddd

<--- Last few GCs --->

[17172:000001E0EEED86A0]   423428 ms: Mark-sweep 1485.5 (1522.0) -> 1485.5 (1522.0) MB, 2817.0 / 0.0 ms  allocation failure GC in old space requested
[17172:000001E0EEED86A0]   426164 ms: Mark-sweep 1485.5 (1522.0) -> 1485.5 (1516.0) MB, 2735.9 / 0.0 ms  last resort gc
[17172:000001E0EEED86A0]   429133 ms: Mark-sweep 1485.5 (1516.0) -> 1485.5 (1516.0) MB, 2969.9 / 0.0 ms  last resort gc


<--- JS stacktrace --->

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

Security context: 000003092D4C0D59 <JS Object>
    2: listener [C:\NodeJS\v5\node_modules\npm\node_modules\npmlog\node_modules\gauge\node_modules\signal-exit\index.js:88] [pc=0000031922938DD5](this=000002CCA2196281 <a process with map 000001E744610B71>)
    3: emitNone(aka emitNone) [events.js:86] [pc=0000031922938B31](this=000003092D404311 <undefined>,handler=0000031F86B79379 <JS Function listener (SharedFunctionInfo 0000031F86B79029)>,i...

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

The JS stack trace seems different from time to time, eg like this:

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

Security context: 0000031DFB2C0D59 <JS Object>
    2: emitNone(aka emitNone) [events.js:86] [pc=000002993916DA71](this=0000031DFB204311 <undefined>,handler=00000360FFC77F41 <JS Function listener (SharedFunctionInfo 00000360FFC77BF1)>,isFn=0000031DFB2043B1 <true>,self=000002EEFFA95499 <a process with map 000000CA9BF10B71>)
    3: emit [events.js:185] [pc=000002993916D5CA](this=000002EEFFA95499 <a process with map 000000CA9BF10B71>,type=000...

Exception "Z" from running node --max_old_space_size=4000 /c/NodeJS/npm help

C:\NodeJS\v5\npm:4
case `uname` in
^^^^
SyntaxError: Unexpected token case
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

I think, not the installation is the problem because i got a working node.js folder from a mate. But I did no configuration until now on this pc (maybe this is the mistake?)

I found the solution to this error in http://www.fatalerrors.org/a/fatal-error-markcompactcollector-semi-space-copy.html . I had an invalid path (partition) in this config. After removing the entry I was able to use npm again.

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