如果你遇到如下的情况
<--- Last few GCs ---> [13724:0000020D39C660D0] 231298 ms: Mark-sweep 1356.3 (1433.6) -> 1356.3 (1433.6) MB, 1194.3 / 0.0 ms allocation failure GC in old space requested [13724:0000020D39C660D0] 232615 ms: Mark-sweep 1356.3 (1433.6) -> 1356.3 (1426.6) MB, 1198.3 / 0.0 ms last resort GC in old space requested [13724:0000020D39C660D0] 233976 ms: Mark-sweep 1356.3 (1426.6) -> 1356.3 (1426.6) MB, 1361.9 / 0.0 ms last resort GC in old space requested ==== JS stack trace ========================================= Security context: 000003D3AF3A5879 <JSObject> 1: forEachTrailingCommentToEmit(aka forEachTrailingCommentToEmit) [D:\workspace\test5\node_modules\@angular-devkit\build- optimizer\node_modules\typescript\lib\typescript.js:~68706] [pc=0000011FBA279296](this=000002F7A0B022D1 <un defined>,end=146101,cb=000002223F807211 <JSFunction emitTrailingCommentOfPosition (sfi = 0000026706B3E149)>) 2: emitTrailingCommentsOfPosition(aka emitTrailingC... FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: node_module_register 2: v8::internal::FatalProcessOutOfMemory 3: v8::internal::FatalProcessOutOfMemory 4: v8::internal::Factory::NewCodeRaw 5: v8::internal::Factory::NewCode 6: v8::internal::modulo 7: v8::internal::compiler::ControlFlowOptimizer::TryBuildSwitch 8: v8::internal::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64>::ZoneVector<v8::internal::compiler::MoveOperands * __ptr64> 9: v8::internal::compiler::Pipeline::AllocateRegistersForTesting 10: v8::internal::compiler::ValueNumberingReducer::operator= 11: v8::internal::CompilationJob::FinalizeJob 12: v8::internal::compiler::InstructionSelector::isolate 13: v8::internal::Compiler::FinalizeCompilationJob 14: v8::internal::OptimizingCompileDispatcher::InstallOptimizedFunctions 15: v8::internal::StackGuard::HandleInterrupts 16: v8::internal::wasm::WasmOpcodes::TrapReasonMessage 17: 0000011FB84843C1
嗯,可以这么解决:
在package.json文件中做如下配置:
"build-prod": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng build --prod"
然后打包的时候 :
npm run build-prod
作者:承蒙时光
出处:http://www.cnblogs.com/timetimetime/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。