首页 > 解决方案 > 致命错误:JavaScript 堆内存不足——Node v12.18.1 和 Nuxt

问题描述

我正在运行Node v12.18.1。在 VSCODE 中处理我的 Nuxt 应用程序并运行以下命令时:

npm run dev

我在 VSCODE 终端中收到以下错误:

i Preparing project for development                                                                                                                                                  03:55:28
i Initial build may take a while                                                                                                                                                     03:55:28  

 WARN  Components directory not found: ~/components/global                                                                                                                           03:55:28  

√ Builder initialized                                                                                                                                                                03:55:28  
√ Nuxt files generated                                                                                                                                                               03:55:28  

√ Client
  Compiled successfully in 7.13s

√ Server
  Compiled successfully in 7.05s

i Waiting for file changes                                                                                                                                                           03:55:36
i Memory usage: 418 MB (RSS: 519 MB)                                                                                                                                                 03:55:36
i Listening on: http://localhost:3000/                                                                                                                                               03:55:36

<--- Last few GCs --->
 a[13632:000001B66F1CB6E0]    52658 ms: Mark-sweep 2045.4 (2052.6) -> 2043.6 (2054.1) MB, 279.7 / 0.0 ms  (+ 255.2 ms in 58 steps since start of marking, biggest step 14.1 ms, walltime since 
start of marking 552 ms) (average mu = 0.113, current mu = 0.032) [13632:000001B66F1CB6E0]    53242 ms: Mark-sweep 2046.8 (2054.4) -> 2045.3 (2055.1) MB, 343.8 / 0.0 ms  (+ 225.6 ms in 49 steps since start of marking, biggest step 14.3 ms, walltime since start of marking 584 ms) (average mu = 0.070, current mu = 0.025) 

<--- JS stacktrace --->

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

    0: ExitFrame [pc: 00007FF68370978D]
Security context: 0x01f57d1008d1 <JSObject>
    1: createComponent(aka createComponent) [0000010ED95B7D81] [C:\Users\nickm\Desktop\work\XXX-nuxt\node_modules\vue\dist\vue.runtime.common.dev.js:~3163] [pc=00000332FBDEFF2C](this=0x018e1e2004b1 <undefined>,0x00dd1d2c3d11 <Object map = 0000005DFCD9D4E9>,0x018e1e2004b1 <undefined>,0x01f079a63321 <VueComponent map = 00000322C22283E9>,0x018e1e2004b...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF682AF51EF napi_wrap+114271
 2: 00007FF682A9FE66 v8::base::CPU::has_sse+66630
 3: 00007FF682AA0C66 v8::base::CPU::has_sse+70214
 4: 00007FF6832B522E v8::Isolate::ReportExternalAllocationLimitReached+94     
 5: 00007FF68329D301 v8::SharedArrayBuffer::Externalize+833
 6: 00007FF68316983C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
 7: 00007FF683174A70 v8::internal::Heap::ProtectUnprotectedMemoryChunks+1312  
 8: 00007FF683171594 v8::internal::Heap::PageFlagsAreConsistent+3204
 9: 00007FF683166D93 v8::internal::Heap::CollectGarbage+1283
10: 00007FF683165404 v8::internal::Heap::AddRetainedMap+2452
11: 00007FF68318660D v8::internal::Factory::NewFillerObject+61
12: 00007FF682EECB2F v8::internal::interpreter::JumpTableTargetOffsets::iterator::operator=+1295
13: 00007FF68370978D v8::internal::SetupIsolateDelegate::SetupHeap+546637
14: 00000332FBDEFF2C 
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! XXX-nuxt-spa@1.0.0 dev: `nuxt`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the XXXX-nuxt-spa@1.0.0 dev 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\XXX\AppData\Roaming\npm-cache\_logs\2020-07-22T08_56_18_678Z-debug.log

i Listening on: http://localhost:3000/注意:在我打开浏览器并尝试通过本地服务器查看我的应用程序之前,不会发生上述错误行。

有人对我如何解决这个问题有任何建议吗?

标签: javascriptnode.jsnuxt.js

解决方案


推荐阅读