question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JS heap size increase not working (--max_old_space_size)

See original GitHub issue

Issue

While build or run my project with create-react-app. It throws js heap out of memory error.

`

yarn build yarn run v1.6.0 $ react-scripts build Creating an optimized production build… <— Last few GCs —> [8792:0000021D06B28B70] 1492086 ms: Mark-sweep 1401.7 (1716.2) -> 1401.7 (1716.2) MB, 1474.4 / 0.0 ms allocation failure GC in old space requested [8792:0000021D06B28B70] 1493542 ms: Mark-sweep 1401.7 (1716.2) -> 1401.5 (1658.7) MB, 1455.7 / 0.0 ms last resort GC in old space requested [8792:0000021D06B28B70] 1494983 ms: Mark-sweep 1401.5 (1658.7) -> 1401.5 (1636.7) MB, 1439.7 / 0.0 ms last resort GC in old space requested <— JS stacktrace —> `

After searching on internet, i found a few suggestions and have added the following lines to my package start and build lines.

“start”: “node --max_old_space_size=4096 node_modules/.bin/react-scripts start”, “build”: “node --max_old_space_size=4096 node_modules/.bin/react-scripts build”

Now when i run “npm start” or “npm build” i get the following error. `

npm start view@0.1.0 start D:\my-apps node --max_old_space_size=4096 node_modules/.bin/react-scripts start D:\my-apps\node_modules.bin\react-scripts:2 basedir=$(dirname “$(echo “$0” | sed -e ‘s,\,/,g’)”) ^^^^^^^ SyntaxError: missing ) after argument list at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:599:28) at Object.Module._extensions…js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3) at Function.Module.runMain (module.js:676:10) at startup (bootstrap_node.js:187:16) at bootstrap_node.js:608:3 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! view@0.1.0 start: node --max_old_space_size=4096 node_modules/.bin/react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the ttc-avl-map-view@0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in:`

Did you try recovering your dependencies?

Yes, the issue exists after deleting node_modules folder and reinstalling through npm

Environment

Environment: OS: Windows 10 Pro Node: 8.9.3 Yarn: 1.6.0 npm: 6.1.0 Watchman: Not Found Xcode: N/A Android Studio: Not Found

Packages: (wanted => installed) react: ^16.2.0 => 16.4.0 react-dom: ^16.2.0 => 16.4.0 react-scripts: 1.1.4 => 1.1.4

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

18reactions
Timercommented, May 31, 2018

This should work:

react-scripts --max_old_space_size=4096 start
0reactions
vongohrencommented, Nov 5, 2018

@Timer @andyliu-417 @bugzpodder is this a viable solution? Or is your bundle acctually getting wrong @andyliu-417 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js heap out of memory - javascript - Stack Overflow
#increase to 1gb node --max-old-space-size=1024 index.js ... I just faced same problem with my EC2 instance t2.micro which has 1 GB memory.
Read more >
How to Fix JavaScript Heap Out of Memory Error - MakeUseOf
In the Variable value field enter --max-old-space-size=4096. This value will allocate 4GB of virtual memory to Node.js. To set a different value ...
Read more >
How to solve JavaScript heap out of memory error
To fix JavaScript heap out of memory error, you need to add the --max-old-space-size option when running your npm command. Here's an example...
Read more >
JavaScript Heap Out Of Memory Error - OpenReplay Blog
Increasing the memory limit is a quick fix to the problem, which in some cases is enough. Other times though, you may not...
Read more >
JavaScript heap out of memory - Snyk Support
Resolution. You can increase the amount of memory allocated to the command by running the following command prior to running the Snyk CLI:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found