我正在使用IONIC 3构建应用程序,而在构建生产应用程序时却遇到了JS问题。
我使用代码ionic cordova build ios --prod
并且出现跟随错误
<--- Last few GCs --->
[2769:0x104000000] 198493 ms: Mark-sweep 8037.6 (8188.4) -> 8037.6 (8189.4) MB, 10477.9 / 0.0 ms (average mu = 0.108, current mu = 0.001) allocation failure scavenge might not succeed
[2769:0x104000000] 211226 ms: Mark-sweep 8038.6 (8189.4) -> 8038.5 (8190.9) MB, 12720.3 / 0.0 ms (average mu = 0.048, current mu = 0.001) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0xc2936adc01d]
1: StubFrame [pc: 0xc2936add3df]
Security context: 0x16d7fc81e681 <JSObject>
2: write [0x16d90d9e6691] [/Users/guifeliper/My Apps/TalkABit2019/node_modules/typescript/lib/typescript.js:~9597] [pc=0xc2936afd123](this=0x16d90d9e6739 <Object map = 0x16d706426959>,s=0x16d7bd9bf491 <String[1]: V>)
3: write(aka write) [0x16d90d9e7021] [/Users/guifeliper/My Apps/TalkABit2019/node_modules/typescrip...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x100039dbf node::Abort() [/usr/local/bin/node]
2: 0x100039fc9 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
3: 0x1001d1375 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
4: 0x10059c572 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
5: 0x10059f045 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
6: 0x10059aeef v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
7: 0x1005990c4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
8: 0x1005a594c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
9: 0x1005a59cf v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
[ERROR] Non-zero exit from subprocess.
我在节点上添加了--max_old_space_size = 4096,但遗憾的是它只会减慢显示错误的速度。我能做什么?
离子信息
Ionic:
ionic (Ionic CLI) : 4.2.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.0.0, ios 4.5.5
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.2.0, (and 5 other plugins)
System:
NodeJS : v10.10.0 (/usr/local/lib/node_modules/node/bin/node)
npm : 5.6.0
OS : macOS
Xcode : Xcode 10.1 Build version 10B61
更新
我完全遵循此环境here,但是现在在firebase上又停止了。它只是停下来而没有说什么。
> cordova build ios
Preparing Firebase on iOS
Building for iPhone X Simulator
Building project: /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/talkaBit.xcworkspace
Configuration: Debug
Platform: emulator
Build settings from command line:
CONFIGURATION_BUILD_DIR = /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/build/emulator
SDKROOT = iphonesimulator12.1
SHARED_PRECOMPS_DIR = /Users/guifeliper/My Apps/TalkABit2019/platforms/ios/build/sharedpch
Build settings from configuration file '/Users/guifeliper/My Apps/TalkABit2019/platforms/ios/cordova/build-debug.xcconfig':
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES
CODE_SIGN_ENTITLEMENTS = $(PROJECT_DIR)/$(PROJECT_NAME)/Entitlements-$(CONFIGURATION).plist
CODE_SIGN_IDENTITY = iPhone Developer
ENABLE_BITCODE = NO
GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1
HEADER_SEARCH_PATHS = "$(TARGET_BUILD_DIR)/usr/local/lib/include" "$(OBJROOT)/UninstalledProducts/include" "$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include" "$(BUILT_PRODUCTS_DIR)"
OTHER_LDFLAGS = -ObjC
SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h
答案 0 :(得分:5)
可以增加节点的最大内存大小:
在终端控制台中:
// Desctructuing: Actual object/array:
const [{ // [{
content: { // "content": {
tabs: [{ // "tabs": [{
sections: foo // "name": "Overview", "id": 1, "sections": {...}
}] // }, ...]
} // }
}] = obj; // }, ...]
如果使用 Windows :
export NODE_OPTIONS=--max_old_space_size=8096
运行ionic build --prod之前
我遇到了同样的问题,这解决了我的问题。 信用:https://github.com/ionic-team/ionic/issues/16868