Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript heap out of memory on npm run client:dev #13529

Closed
JohnDoe453 opened this issue Oct 3, 2021 · 14 comments
Closed

JavaScript heap out of memory on npm run client:dev #13529

JohnDoe453 opened this issue Oct 3, 2021 · 14 comments

Comments

@JohnDoe453
Copy link

General Info

  • UUID: -
  • Browser: -
  • OS: Windows

Description

While setting up the project locally, running npm run client:dev gives JavaScript heap out of memory error

Console Errors

<--- Last few GCs --->


[37:0x4af69a0]   291368 ms: Scavenge 1176.6 (1533.9) -> 1160.6 (1533.9) MB, 2.1 / 0.0 ms  (average mu = 0.925, current mu = 0.893) allocation failure 

[37:0x4af69a0]   291386 ms: Scavenge 1176.6 (1533.9) -> 1160.6 (1533.9) MB, 2.5 / 0.0 ms  (average mu = 0.925, current mu = 0.893) allocation failure 

[37:0x4af69a0]   291409 ms: Scavenge 1176.6 (1533.9) -> 1160.6 (1533.9) MB, 6.0 / 0.0 ms  (average mu = 0.925, current mu = 0.893) allocation failure 



<--- JS stacktrace --->


FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory

 1: 0xa389b0 node::Abort() [node]

 2: 0x96e0af node::FatalError(char const*, char const*) [node]

 3: 0xbb7a4e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]

 4: 0xbb7dc7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]

 5: 0xd73fd5  [node]

 6: 0xd4c805  [node]

 7: 0xed64ee  [node]

 8: 0xed663d  [node]

 9: 0x1074b83 v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [node]

10: 0x1446379  [node]

Aborted

npm ERR! code ELIFECYCLE

npm ERR! errno 134

npm ERR! [email protected] serve: `vue-cli-service serve`

npm ERR! Exit status 134

npm ERR! 

npm ERR! Failed at the [email protected] serve script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
@SneakySensei
Copy link

I would like to pick this up. Can you assign it to me?

@JohnDoe453
Copy link
Author

This doesn't fix the issue.

@SneakySensei
Copy link

@JohnDoe453 Can you elaborate a bit more? It doesn't happen on my pc. But setting --max_old_space_size to a bigger value is the way to fix this. Is it happening for all devs? Does it happen only on windows? What's the system specifications of the said system?

@danndylan
Copy link

danndylan commented Oct 13, 2021

@SneakySensei
Hi. is this the only fix for the said error? I'm experiencing the same issue and tried the fix but it is not working.
I'm also using windows 10 on i3 processor, 16gb ram pc.

Here's a gist of my error logs
https://gist.github.com/danndylan/d8b350b13d966ba245f5161b0237d4d9

What I tried:

  • clean reinstall of node_modules. delete node_modules -> clean cache -> npm ci
  • add options to serve script in package.json as suggested here and from my online searches:
    "serve": "vue-cli-service serve --max_old_space_size=3000 --trace-gc-verbose",

Any help would be appreciated. Thank you!

@jasonmishi
Copy link
Contributor

Hi, I too do not have this issue but did scour the web for solutions,
One might be to edit the package.json to say:
"serve": "npx --max_old_space_size=4096 vue-cli-service serve"
as suggested in this thread vuejs/vue-cli#1453 (comment). This is untested by me so I have no idea if it will work or not.

@danndylan
Copy link

Hi, I too do not have this issue but did scour the web for solutions, One might be to edit the package.json to say: "serve": "npx --max_old_space_size=4096 vue-cli-service serve" as suggested in this thread vuejs/vue-cli#1453 (comment). This is untested by me so I have no idea if it will work or not.

Hi, i tried making the changes in package.json but the error is still the same

npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! [email protected] serve: `npx --max_old_space_size=4096 vue-cli-service serve`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I also tried setting up using docker, but im still having the same error when it comes to running npm run client:dev. not sure if the issue is with my machine

@SabreCat
Copy link
Member

SabreCat commented Dec 13, 2021

Attempted fix didn't take for some people, and the PR author hasn't been responding. Opening this back up for contributors to investigate!

@phorcys420
Copy link

The real NodeJS arg to increase heap space would be --max-old-space-size=4096, and NOT using underscores.

This is what I use when that problem occurs (mostly when using bundlers such as rollup).
Set 4096 (4G) to the amount you desire, except 4096 mostly will do the trick.

@CuriousMagpie
Copy link
Member

@phorcys420 Could you put together a PR for this?

@citrusella
Copy link
Contributor

I just tried that last one and still hit the issue with 4096 as the size... but I'm inept enough at this particular thing that it's possible I messed up where or how to put it, even though it SEEMED like I did it right...

(I was trying it on my local install purely because I was going through the entire installation on a new device and have been itching to make sure the install actually, like, worked. But maybe I've gotten ahead of myself and should wait for someone more skilled to fix it.)

@phorcys420
Copy link

phorcys420 commented Jan 10, 2022

@phorcys420 Could you put together a PR for this?

I mean.. sure ? I don't really see the point though.
My PR would straight up just be one singular line change in https://github.com/HabitRPG/habitica/blob/develop/website/client/package.json

Likely,

"serve": "vue-cli-service serve",

to

"serve": "NODE_OPTIONS=--max-old-space-size=4096 vue-cli-service serve",

EDIT: tried to get a dev env running, everything literally exploded, had around 3 warnings for 100+ vulnerabilities each.
vue-cli-service just straight up dies

@CuriousMagpie
Copy link
Member

Huh, that's weird. Did you follow the instructions on the Setting up Habitica Locally wiki page?

@SabreCat
Copy link
Member

SabreCat commented Feb 4, 2022

"serve": "NODE_OPTIONS=--max_old_space_size=4096 vue-cli-service serve",

Isn't this exactly the fix that was attempted already? I thought you said we needed a not underscored parameter?

@JanStefanski
Copy link

JanStefanski commented Apr 11, 2022

Hey, I struggled with the same issue, but as for me the problem was fixed by deleting local copy of the repo and cloning it again, with small change, I've ran git config --global core.autocrlf input as it's written in wiki. (Docker on Windows). Looks like wrong line endings were the issue in my case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants