0

I am trying to build a create-react-app with react-plotly.js but when the plot components are included the compiler hangs and eventually fails displaying the error:

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

I checked the node heap limit using this command:

node -e 'console.log(`node heap limit = ${require("v8").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'

which returned:

node heap limit = 1456.1747760772705 Mb

I am using the WSL 2 Linux subsystem for Windows.

I have tried editing the package.json and replacing react-scripts start with node --max_old_space_size=4096 node_modules/.bin/react-scripts start as suggested in this answer but the error was the same. I have also tried reducing it and using 512 as I have read that is sometimes advised if there is not enough space on the machine.

Any ideas how I can get this to work?

Graham Hesketh
  • 317
  • 3
  • 16

1 Answers1

1

I had success resolving this issue by disabling the GENERATE_SOURCEMAP flag in my .env file, ie

GENERATE_SOURCEMAP=false

as suggested by the (slightly unrelated) answer here.

Chris
  • 11
  • 2