Ricardo Saracino
Ricardo Saracino

Reputation: 1420

npm pack "JavaScript heap out of memory"

Trying to do a npm pack command and i am running out of memory i was reading that you can use the --max_old_spacesize=5000 but is was referencing node as the command.

running npm 6.2.0 and node v10.8.0

λ npm pack --max_old_spacesize=5000

<--- Last few GCs --->

[13984:0000029D62F6ADE0]    54691 ms: Scavenge 1389.1 (1423.3) -> 1388.5 (1423.8) MB, 4.1 / 0.0 ms  (average mu = 0.269, current mu = 0.228) allocation failure
[13984:0000029D62F6ADE0]    54699 ms: Scavenge 1389.3 (1423.8) -> 1388.7 (1424.8) MB, 3.9 / 0.0 ms  (average mu = 0.269, current mu = 0.228) allocation failure
[13984:0000029D62F6ADE0]    54707 ms: Scavenge 1389.5 (1424.8) -> 1388.9 (1425.3) MB, 3.8 / 0.0 ms  (average mu = 0.269, current mu = 0.228) allocation failure


<--- JS stacktrace --->

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

    0: ExitFrame [pc: 00000331D7D041C1]
Security context: 00000213F4C9E789 <JSObject>
    1: readdir [0000036E25004921] [fs.js:~732] [pc=00000331D7DE11B2](this=000002C39D502201 <Object map = 0000005BBB80DBA1>,path=000003C3A8536779 <String[81]: C:\Users\Ricardo Saracino\IdeaProjects\nest-SOR\node_modules\es5-ext/node_modules>,options=000003C3A8536859 <JSFunction go$readdir$cb (sfi = 000002689D76D399)>,callback=000000891C8022E1 <undefined>)...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF6867E9055
 2: 00007FF6867C2FE6
 3: 00007FF6867C38C0
 4: 00007FF686C171DE
 5: 00007FF686C17113
 6: 00007FF686C8C004
 7: 00007FF686C82AE7
 8: 00007FF686C8106C
 9: 00007FF686C89CC5
10: 00007FF686AC3537
11: 00007FF686CF879A
12: 00000331D7D041C1

Upvotes: 3

Views: 4903

Answers (2)

Orelsanpls
Orelsanpls

Reputation: 23495

You can use of :

node --max_old_space_size=8000 /usr/bin/npm pack

As said by @daavve in here

(we love dave)

enter image description here

Upvotes: 4

Ricardo Saracino
Ricardo Saracino

Reputation: 1420

I had to edit the file C:\Program Files\nodejs\npm.cmd on windows

"%NODE_EXE%" --max-old-space-size=8000 "%NPM_CLI_JS%" %*

As suggested here https://github.com/npm/npm/issues/12238

Upvotes: 2

Related Questions