angular4+ionic3 运行报错 Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 解决办法

项目框架:angular4 + ionic3

执行 npm run ionic:serve 运行时报错 Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

报错代码如下:

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0000008892B5C5C1]
Security context: 0x038b15f9e6e9 
    1: nextToken [00000020268433D9] [D:\knx\vxMobile\node_modules\postcss\lib\tokenize.js:~66] [pc=000000889419ECB9](this=0x002026843419 )
    2: parse [0000015C88944011] [D:\knx\vxMobile\node_modules\postcss\lib\parser.js:~52] [pc=0000008894190AAC](this=0x002026843449 )
    3: parse(aka parse) ...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF7FDB3F04A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+5114
 2: 00007FF7FDB1A0C6 node::MakeCallback+4518
 3: 00007FF7FDB1AA30 node_module_register+2032
 4: 00007FF7FDDA20EE v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF7FDDA201F v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF7FE2C2BC4 v8::internal::Heap::MaxHeapGrowingFactor+9556
 7: 00007FF7FE2B9C46 v8::internal::ScavengeJob::operator=+24310
 8: 00007FF7FE2B829C v8::internal::ScavengeJob::operator=+17740
 9: 00007FF7FE2C0F87 v8::internal::Heap::MaxHeapGrowingFactor+2327
10: 00007FF7FE2C1006 v8::internal::Heap::MaxHeapGrowingFactor+2454
11: 00007FF7FDE7CDB7 v8::internal::Factory::NewFillerObject+55
12: 00007FF7FDF12CC6 v8::internal::WasmJs::Install+29414
13: 0000008892B5C5C1
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! Vxmobile-ionic@ ionic:serve: `node copy-env-config.js --env dev | ionic-app-scripts serve --max_old_space_size=4096`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the Vxmobile-ionic@ ionic:serve 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!     C:\Users\shawang\AppData\Roaming\npm-cache\_logs\2020-04-29T07_18_48_488Z-debug.log 
  
 

 

解决办法:

修改package.json scripts ionic:serve

ionic-app-scripts serve 后面添加 --max_old_space_size=8192

{
  "name": "xxx",
  "author": "xxx",
  "homepage": "xxx",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "node copy-env-config.js --env prod | node --max-old-space-size=8192 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build",
    "ionic:serve": "node copy-env-config.js --env dev | ionic-app-scripts serve --max_old_space_size=8192"
  },
  ...
}

4096不够的话就可以用8192试试

 

你可能感兴趣的:(angular4+ionic3 运行报错 Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 解决办法)