Using ubuntu 20.04 and node 14.16.1, I had same error reinstalling node fixed the issue. I had tried the following methods:

  • I tried to augment ram swap space to 20G because it was full.

  • I tried to use computer with 8G ram instead of 4G.

  • I tried to start with flag to use more ram in package json start script

    "start": "node --max_old_space_size=8196 node_modules/.bin/react-scripts start"

  • I created .env file with


Every time remove node-modules. (package lock was working for my colleague)


Using Windows (x64) and Node v14.15.1

I tried to allocate memory manually and stil got no results.

Finally i uninstalled the next dependency from my project and used npm i next@latest to upgrade to Next 11.1.2 and I've got rid of the problem.

Upgrading Next from

Now I can run npm run buil npm run start and my app is back running.

Took a look at the memory heap snapshot and looks like nothing annusual.


Solved!!! (For Angular) After hours of trying to solve this, I finally identified that the reason I keep on getting that error despite trying to increase max_old_space_size is because I had installed the x86 (32bit) version of Node.js on a 64bit computer.

After I saw this I:

  1. deleted chocolatey from C:\ProgramData\chocolatey\bin
  2. uninstalled the x86 (32bit) version on node.js
  3. deleted npm & npm cache folders from C:\Users\%username%\AppData\Roaming
  4. restarted my computer
  5. installed the x64 version of node
  6. reinstalled angular/cli npm install -g @angular/cli
  7. complied my projects & everything worked without any errors


There might certainly be no need increasing the processing time. It might interest you to know that problems of this sort are raised when the 'forEach' loop structure is used; rather than the classical for-loop'. So, I'd advice that you check the functions being called and change whatever 'forEach' structure you've got to a classical 'for-loop'. Especially when you've got database transactions, send emails etc in these loops.


Just wanted to add another item to check here, if all the other suggested answers don't resolve the issue:

I accidentally set in my .yarnrc file --modules-folder src/.node_modules. I don't know why, just wasn't thinking, silly of me.

As a result, all of the .node_modules content - hundreds of MB of source code - was pulled into the build when I ran yarn build (which was mapped to react-scripts build).

So if the other answers fail to solve your issue, check to see if you are potentially mis-configuring your .node_modules directory, make sure it is not inside src.


Using Next.js version 10.2.0

In my case I got past this error by specifying target: 'server' instead of target: 'serverless' in the next.config.js file. This made the source maps in development smaller - from over 100MB to around 10MB.

My CI runner with 2GB probably couldn't provided the amount of memory required to create the large source maps required for Next.js's serverless setup

Old next.config.js:

module.exports = {
  target: 'serverless',

New next.config.js:

module.exports = {
  target: 'server',


I solved this issue in react js by running the following command in terminal

set NODE_OPTIONS=--max_old_space_size=8096


In my case this error was caused by the fact that I imported twice the same less files:

@import "~@myPackage/file1.less";
@import "~@myPackage/file1.less";

@import "~@myPackage/file2.less";
@import "~@myPackage/file2.less";


I had the same error. Fixed it by using an earlier version of Node/npm. Might fix your problem.


its because more "js" files in your react Application. You can build your application after making some Changes in package.json like below of code:

"scripts": {
        "start": "react-scripts --max_old_space_size=4096 start",
        "build": "react-scripts --max_old_space_size=4096 build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"


The root cause of the issue is due to large source file sizes.
If the underline problem is within your source code you can resolve it by simply increasing the Node Heap Size as below,

"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
But if the problem lies within any dependencies introduced, we may need to increase the Node Heap allocation globally to resolve the issue.

For Windows:

set NODE_OPTIONS=--max_old_space_size=4096

For Linux:

export NODE_OPTIONS=--max_old_space_size=4096


I had a similar heap allocation error while deploying to Heroku. The app would still build correctly but would not load in the browser. Heroku logs would show me this: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

After trying a dozen different things this seemed to work in package.json:

 "start": "react-scripts --max_old_space_size=4096 start",
 "build": "react-scripts --max_old_space_size=4096 build",


That problem is related with large files in your project.

I'm using create-react-app, and I got that error, after doing some search, it seems one solution is this.

Put in .env file:


Related Query

More Query from same tag