4

I am new in nodejs i have installed nodejs successfully, when i init the npm i am getting aborted error.

I have a lot of memory means 32GB RAM and 1TB HD.

Only npm -v command working rest all command not working with npm.

Please see the below error and help me.

[xyz@server node]$ npm init

<--- Last few GCs --->

[13396:0x4389aa0]      126 ms: Scavenge 6.3 (10.8) -> 5.2 (11.8) MB, 1.2 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure
[13396:0x4389aa0]      168 ms: Scavenge 7.7 (12.3) -> 6.7 (12.8) MB, 2.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure
[13396:0x4389aa0]      215 ms: Scavenge 8.5 (12.8) -> 7.6 (16.8) MB, 12.3 / 0.0 ms  (average mu = 1.000, current mu = 1.000) allocation failure


<--- JS stacktrace --->
Cannot get stack trace in GC.
FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory
 1: 0x89a0c0 node::Abort() [npm]
 2: 0x89a10c  [npm]
 3: 0xa879be v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [npm]
 4: 0xa87bd8 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [npm]
 5: 0xe753e2  [npm]
 6: 0xea6376 v8::internal::MarkCompactCollector::Evacuate() [npm]
 7: 0xea69d2 v8::internal::MarkCompactCollector::CollectGarbage() [npm]
 8: 0xe808b1 v8::internal::Heap::MarkCompact() [npm]
 9: 0xe80fb1 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [npm]
10: 0xe81c74 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [npm]
11: 0xe845a5 v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [npm]
12: 0xe4d3b8 v8::internal::Factory::NewFeedbackVector(v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::PretenureFlag) [npm]
13: 0xe29453 v8::internal::FeedbackVector::New(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SharedFunctionInfo>)[npm]
14: 0xf77319 v8::internal::JSFunction::EnsureFeedbackVector(v8::internal::Handle<v8::internal::JSFunction>) [npm]
15: 0xd9e60a v8::internal::Compiler::Compile(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::Compiler::ClearExceptionFlag) [npm]
16: 0x10b9822 v8::internal::Runtime_CompileLazy(int, v8::internal::Object**, v8::internal::Isolate*) [npm]
17: 0x3f6b33a041bd
Aborted
2

1 Answer 1

6

One way to overcome the FATAL ERROR: NewSpace::Rebalance Allocation failed - JavaScript heap out of memory error is to increase the memory allocation, for which we need to set the the max_old_space_size variable value accordingly,

For e.g,

node --max-old-space-size=1024 index.js => This will allocate 1GB memory.

Hence try increasing it like,

node --max_old_space_size=2048 and once done execute your npm init command.

Hope this helps!

Sign up to request clarification or add additional context in comments.

14 Comments

Thanks for Solution but it is not working. I am getting same error.
@eharajhusain Probably you can increase the current 2048 value, or else better try this npm package => increase-memory-limit
i used this but npm command is not working got same error. Main problem with npm command it is not working whatever i run with npm got same error.
Ah.. I can understand the issue now.
@eharajhusain Goto command prompt, type node hit enter then execute process.memoryUsage() and post what you receive there.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.