nuxt: nuxi start produces error when previewing
While building like this command nuxi build it produces the following
Nuxt CLI v3.0.0-27501460.04a72f8 03:32:34
i Merging Tailwind config from ~/tailwind.config.js nuxt:tailwindcss 03:32:36
i Vite client warmed up in 4269ms 03:32:41
WARN 03:32:44
(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
i Client built in 6965ms 03:32:44
i Building server... 03:32:44
√ Server built in 918ms 03:32:45
√ Generated public .output/public nitro 03:32:46
start Building server... nitro 03:32:46
start Writing server bundle... nitro 03:32:50
√ Server built nitro 03:32:50
├─ .output/server/package.json (1.4 kB) (534 B gzip)
├─ .output/server/index.mjs (372 B) (205 B gzip)
├─ .output/server/chunks/vue3.mjs (283 B) (197 B gzip)
├─ .output/server/chunks/static.mjs (5.98 kB) (1.83 kB gzip)
├─ .output/server/chunks/server.mjs (243 kB) (48.4 kB gzip)
├─ .output/server/chunks/renderer.mjs (23.3 kB) (6.46 kB gzip)
├─ .output/server/chunks/node-server.mjs (12.1 kB) (3.96 kB gzip)
├─ .output/server/chunks/index.mjs (397 kB) (91.6 kB gzip)
└─ .output/server/chunks/client.manifest.mjs (3.07 kB) (555 B gzip)
Σ Total size: 6.45 MB (1.52 MB gzip)
i You can preview this build using node .output/server/index.mjs nitro 03:32:51
- While starting it. using
nuxi build
Listening on http://localhost:3000/
<--- Last few GCs --->
[11080:00000215A353BDA0] 57470 ms: Mark-sweep (reduce) 4096.1 (4105.6) -> 4086.6 (4096.2) MB, 15.4 / 0.0 ms (average mu = 0.696, current mu = 0.701) allocation failure scavenge might not succeed
[11080:00000215A353BDA0] 57499 ms: Mark-sweep (reduce) 4096.1 (4105.7) -> 4096.1 (4105.7) MB, 15.3 / 0.0 ms (average mu = 0.612, current mu = 0.469) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF7DF82815F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
2: 00007FF7DF7B54C6 DSA_meth_get_flags+65542
3: 00007FF7DF7B637D node::OnFatalError+301
4: 00007FF7E00EBA0E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF7E00D5FED v8::SharedArrayBuffer::Externalize+781
6: 00007FF7DFF793BC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
7: 00007FF7DFF764D4 v8::internal::Heap::CollectGarbage+4244
8: 00007FF7DFF73E50 v8::internal::Heap::AllocateExternalBackingStore+2000
9: 00007FF7DFF91B60 v8::internal::FreeListManyCached::Reset+1408
10: 00007FF7DFF92215 v8::internal::Factory::AllocateRaw+37
11: 00007FF7DFFA78EB v8::internal::FactoryBase<v8::internal::Factory>::NewRawOneByteString+75
12: 00007FF7DFD8B16B v8::internal::String::SlowFlatten+395
13: 00007FF7DFAF53CB v8::internal::WasmTableObject::Fill+603
14: 00007FF7DFCDD309 v8::internal::RegExp::ExperimentalOneshotExec+1161
15: 00007FF7DFCDCDC7 v8::internal::RegExp::Exec+199
16: 00007FF7DFCB8C7C v8::internal::DeclarationScope::was_lazily_parsed+21452
17: 00007FF7E0179701 v8::internal::SetupIsolateDelegate::SetupHeap+494417
18: 00007FF7E01D0AF3 v8::internal::SetupIsolateDelegate::SetupHeap+851779
19: 00007FF7E016D284 v8::internal::SetupIsolateDelegate::SetupHeap+444116
20: 00000215A539E54B
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 16 (4 by maintainers)
While I haven’t been able to produce a minimal reproduction today, I was able to get a working workaround. It would build fine, but running and visiting the demo server would produce the same memory error reported by @anburocky3
I added the troublesome module (
lodashin my case) to thenoExternallist in the nuxt.config and this seemed to resolve the issue.nuxt.config.tsI found this problem when using the crypto JS library
Having
crypto-jsas a dependency for a server route, I also had this error and I resolved it by allowingviteNodein the nuxt.config file :I also needed to add
.jsfor my crypto-js imports, for example :import cryptoAES from 'crypto-js/aes.jsI was seeing the same problem. In my case, it’s because I’m using vue3-datepicker. I don’t understand why a date picker package makes the engine run out of memory. Currently, my solution is not to use the vue3-datepicker.
I no longer see this error, might be seeing it randomly, will close this for now, if i have any problem in the future, will reopen it.
@oyed Thanks for your response.
As the error says, the JS heap ran out of memory - to increase it, try adding this env var:
NODE_OPTIONS="--max_old_space_size=4096"You can prepend it to your
package.jsonscripts, i.e."build": "NODE_OPTIONS=\"--max_old_space_size=4096\" nuxi build"