Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my react project crashing when updating from react-scripts 3.2.0 to 3.3.0?

I updated my react project using

npm install --save --save-exact [email protected]

But when I start my react project I get this...

Starting the development server...

<--- Last few GCs --->

[27403:0x108000000] 53085 ms: Scavenge 2041.3 (2049.1) -> 2040.6 (2049.4) MB, 7.8 / 0.0 ms (average mu = 0.242, current mu = 0.164) allocation failure [27403:0x108000000] 53094 ms: Scavenge 2041.8 (2049.9) -> 2041.2 (2050.1) MB, 7.7 / 0.0 ms (average mu = 0.242, current mu = 0.164) allocation failure [27403:0x108000000] 53101 ms: Scavenge 2042.0 (2050.1) -> 2041.3 (2050.6) MB, 5.2 / 0.0 ms (average mu = 0.242, current mu = 0.164) allocation failure

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x100930c99]
1: StubFrame [pc: 0x1008e42a7] Security context: 0x3d30707408a1 <JSObject>
2: SourceMapConsumer_allGeneratedPositionsFor [0x3d307ed12519] [/Users/bob/IdeaProjects/test-client/node_modules/source-map/lib/source-map-consumer.js:~178]

[pc=0x183302d049b6](this=0x3d30ec3c01a1 ,0x3d303d727d61 ) 3: /* anonymous */(aka /...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Writing Node.js report to file: report.20200103.163000.27403.0.001.json Node.js report completed 1: 0x10007e9b3 node::Abort() [/usr/local/bin/node] 2: 0x10007eb37 node::OnFatalError(char const*, char const*) [/usr/local/bin/node] 3: 0x100176337 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node] 4: 0x1001762d3 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node] 5: 0x1002fa485 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node] 6: 0x1002fbb54 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node] 7: 0x1002f8a27 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node] 8: 0x1002f6a0d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node] 9: 0x100302124 v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/local/bin/node] 10: 0x10030219f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/usr/local/bin/node] 11: 0x1002ced97 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType) [/usr/local/bin/node] 12: 0x1005f83e5 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node] 13: 0x100930c99 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/usr/local/bin/node] 14: 0x1008e42a7 Builtins_KeyedLoadIC_Megamorphic [/usr/local/bin/node] 15: 0x183302d049b6 16: 0x183302b03a05 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] 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: npm ERR!
/Users/bob/.npm/_logs/2020-01-03T21_30_01_170Z-debug.log ```

Why is this happening?

like image 238
Eric Smith Avatar asked Jan 03 '20 21:01

Eric Smith


People also ask

What is the react build script and what are its benefits?

That’s one of the major benefits of the build script. The other is performance; as you know, development mode is not optimized for production environments. And React uses the build script to ensure that the finished project is bundled, minified, and optimized with best practices for deployment. The script can be run with the following commands.

Is it possible to run ReactJS 17 app in Visual Studio?

I have a ReactJS 17 app in Visual Studio with .Net Core 3.1 (No Redux) I can run the app locally from Visual Studio with no issues. I have tried clearing the npm cache by deleting the package-lock.json, deleting the npm_modules folder, and running npm cache clean --force followed by npm install

Is it better to eject or install react-scripts?

It’s better, anyway. To run the command on the terminal, type the following command. Ejecting helps you to customize anything in your React configuration, but ejecting may create different versions of react-scripts. Then, you have to maintain customized react-scripts yourself with every React project.

What is react-scripts?

Fortunately, today we have Create React App, a handy module that comes with an outstanding configuration, and a scripts command called react-scripts that makes it much easier to build React applications.


1 Answers

It is an issue in the new release. To resolve this, try to allocate more memory. You can do it in two ways:

  • Add this below line in the .bash_profile

export NODE_OPTIONS=--max-old-space-size=8192

  • Change the line in package.json to below way:

"scripts": { "start": "react-scripts --expose-gc --max-old-space-size=8192 start", "build": "react-scripts --expose-gc --max-old-space-size=8192 build", ... ... }

like image 128
jenac Avatar answered Oct 26 '22 17:10

jenac