Increase JavaScript Heap size in create-react-app project
Thanks a lot to @dan-abramov as his comment is the answer! (Give him the vote up in case you come across this).
You can just put e.g. node --max_old_space_size=4096 node_modules/.bin/react-scripts start
in there instead of react-scripts start
Getting an out of memory error while using Create React App and Plotly.js
There are a couple issues reported regarding this exact problem on the repo issues tracking, like:
- JavaScript heap out of memory error with the quickstart Plot example.
- Javascript runs out of memory when making production build
In these issues, we clearly see this is a problem with NodeJS <= 10 memory allocation issue and there are several solutions to this:
Try to upgrade your NodeJS version to latest 12.x versionNode >= 12 increases the heap sizes automatically and it will work. I suggesst you install Node Version Manager (nvm) for Windows which will allow you quickly and easily install and switch through multiple node version.
Manually increasemax_old_space_size
to React scriptsIncrease heap size using max_old_space_size
by adding this option with a memory size into the package.json
script:
"scripts": {
...
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
...
}
Use Partial bundlesPartial bundlesStarting in
v1.15.0
, plotly.js also ships with several partial bundles:
- basic
- cartesian
- geo
- ...
Starting in
v1.39.0
, each plotly.js partial bundle has a corresponding npm package with no dependencies.Starting in
v1.50.0
, the minified version of each partial bundle is also published to npm in a separate "dist min" package.plotly.js basic
The basic partial bundle contains trace modules scatter, bar and pie.
You can load the library from plotly.js-basic-dist
which it's compiled and will consume less memory when bundling:
import React from "react";
// import Plot from "react-plotly.js";
import Plotly from "plotly.js-basic-dist";
import createPlotlyComponent from "react-plotly.js/factory";
const Plot = createPlotlyComponent(Plotly);
Related Topics
Why Is the Onclick Event Triggered Twice
How to Import Modules from All Files in a Directory, Using a Wildcard
Jquery Get Closest Td Text Value
Reprompt for Permissions With Getusermedia() After Initial Denial
How to Add Pm or Am Based on Hour from Input
How to Toggle (Hide/Show) Sidebar Div Using Jquery
Typescript Property Does Not Exist on Type {}
Validate Phone Number With Yup
React Native: Image Not Displaying With Dynamic/Local Uri
How to Make a Owl Carousel With Arrows Instead of Next Previous
How to Save an Image to Localstorage and Display It on the Next Page
How to Validate This Select Option If Not Selected
How to Remove the X-Axis from a Bar Chart Produced by Google'S Visualization API
Formatting a Number to Have Commas At Every 1000 Factor
How to Match Only the Exact Word Using Indexof or Includes in JavaScript