构建 Microsoft CodePush 时接收内存不足的 javascript 堆

我只在构建 CodePush 版本时收到此错误。


$appcenter codepush release-react -a APPNAME.com/APPNAME-ios -d Production --mandatory --output-dir ./build -t 1.x.x;


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

transform[stderr]: 

transform[stderr]: Writing Node.js report to file: report.20191010.093411.22661.001.json

transform[stderr]: Node.js report completed

transform[stderr]:  1: 0x100062df2 node::Abort() [/usr/local/bin/node]

transform[stderr]:  2: 0x1000634eb node::OnFatalError(char const*, char const*) [/usr/local/bin/node]

transform[stderr]:  3: 0x1001aeda7 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]

transform[stderr]:  4: 0x1001aed44 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]

transform[stderr]:  5: 0x1005b5bd2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]

transform[stderr]:  6: 0x1005b8103 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]

transform[stderr]:  7: 0x1005b4638 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]

transform[stderr]:  8: 0x1005b27f5 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]

transform[stderr]:  9: 0x1005bf09c v8::internal::Heap::AllocateRawWithLightRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]

transform[stderr]: 10: 0x1005bf11f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]

我如何告诉 AppCenter 使用max_old_space_size=8192?


慕村225694
浏览 132回答 3
3回答

30秒到达战场

这说明了您的问题的解决方案。在 Android 上,将以下内容添加到项目的 build.gradle 文件中:project.ext.react = [nodeExecutableAndArgs: ["node", "--max_old_space_size=8192"]]在 iOS 上,在 Xcode 中,选择您的目标并转到 Build Phases 选项卡,在 Bundle React Native code and images 部分中,将标志添加到 shell 脚本:export NODE_BINARY="'node --max_old_space_size=8192'../node_modules/react-native/packager/react-native-xcode.sh"希望这可以帮助!

弑天下

将这些添加到您的脚本中,然后按顺序运行它们。"setup-fix-memory-limit": "npm install -g increase-memory-limit","fix-memory-limit": "cross-env LIMIT=4096 increase-memory-limit",将第二个脚本中的数字更改为您想要的数字。npm run setup-fix-memory-limitnpm run fix-memory-limit还要确保查看是否可以通过其他方式解决,也许一些不正确的导入会显着增加包的大小,使用包分析器查看构建中的内容是否应该是它们的,或者是否可以修剪任何内容。

缥缈止盈

我在 Bitrise 上运行 codepush 时遇到了同样的问题。通过将其导出到CODE_PUSH_NODE_ARGS环境变量来解决。export CODE_PUSH_NODE_ARGS='--max_old_space_size=8192'appcenter codepush release-react ...
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript