问题
I updated my react project using
npm install --save --save-exact react-scripts@3.3.0
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! dms-test-clientnp@0.1.0 start:
react-scripts start
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the dms-test-clientnp@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: npm ERR!
/Users/bob/.npm/_logs/2020-01-03T21_30_01_170Z-debug.log ```
Why is this happening?
回答1:
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", ... ... }
来源:https://stackoverflow.com/questions/59585664/why-is-my-react-project-crashing-when-updating-from-react-scripts-3-2-0-to-3-3-0