我还尝试了$env:NODE_OPTIONS=“--max old space size=8000”,并将我的最大内存设置为8000,每当我npm运行build时,它都会出现相同的错误
所以我无法部署
我有8GB RAM,我不知道我还能做什么。
PS C:\Users\91955\Desktop\SFmovies\frontend> npm run build
> frontend@0.1.0 build
> react-scripts build
Creating an optimized production build...
<--- Last few GCs --->
[17892:000001D77EA8E2A0] 36182 ms: Scavenge 2034.0 (2082.8) -> 2032.4 (2083.0) MB, 3.1 / 0.0 ms (average mu = 0.183, current mu = 0.156) allocation failure
[17892:000001D77EA8E2A0] 36186 ms: Scavenge 2034.5 (2083.0) -> 2032.8 (2083.3) MB, 2.5 / 0.0 ms (average mu = 0.183, current mu = 0.156) allocation failure
[17892:000001D77EA8E2A0] 36190 ms: Scavenge 2035.0 (2083.5) -> 2033.3 (2087.8) MB, 2.5 / 0.0 ms (average mu = 0.183, current mu = 0.156) allocation failure
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF6526730AF v8::internal::CodeObjectRegistry::~CodeObjectRegistry+112511
2: 00007FF652602216 DSA_meth_get_flags+65542
3: 00007FF6526030CD node::OnFatalError+301
4: 00007FF652F34B6E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF652F1F09D v8::SharedArrayBuffer::Externalize+781
6: 00007FF652DC268C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
7: 00007FF652DCF339 v8::internal::Heap::PublishPendingAllocations+1129
8: 00007FF652DCC30A v8::internal::Heap::PageFlagsAreConsistent+2842
9: 00007FF652DBEF89 v8::internal::Heap::CollectGarbage+2137
10: 00007FF652DBD140 v8::internal::Heap::AllocateExternalBackingStore+2000
11: 00007FF652DE1A76 v8::internal::Factory::NewFillerObject+214
12: 00007FF652B14CB5 v8::internal::DateCache::Weekday+1797
13: 00007FF652FC2541 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 000001D701EE9A38
通过在我的package.json中的“scripts”
下添加这个解决了我的问题
"build": "react-scripts --max_old_space_size=4096 build"
我的包.json,如果你有任何疑问..
Package.json屏幕截图