nuxt: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Environment

Nuxt project info:


  • Operating System: Linux
  • Node Version: v18.16.0
  • Nuxt Version: 3.7.4
  • CLI Version: 3.9.0
  • Nitro Version: 2.6.3
  • Package Manager: npm@9.5.1
  • Builder: -
  • User Config: runtimeConfig, css, vite, modules, nitro, app, hooks
  • Runtime Modules: @invictus.codes/nuxt-vuetify@0.3.0, @pinia/nuxt@0.4.11, dayjs-nuxt@2.1.9
  • Build Modules: -

Reproduction

When using an EC2 t2.medium instance and running the npm run build command, I consistently encounter a FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory error after transforming more than 1016 modules. After researching potential solutions, I attempted to increase the memory allocation by setting export NODE_OPTIONS="--max-old-space-size=4096". Although this resolved the initial memory error, the build process still hangs during the module building phase.

The package.json configuration is

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "devDependencies": {
    "@invictus.codes/nuxt-vuetify": "^0.3.0",
    "@nuxt/devtools": "latest",
    "dayjs-nuxt": "^2.1.9",
    "nuxt": "^3.7.4",
    "sass": "^1.69.0",
    "sass-loader": "^13.3.2"
  },
  "overrides": {
    "vue": "latest",
    "mlly": "1.4.0"
  },
  "dependencies": {
    "@pinia/nuxt": "^0.4.11",
    "@vueup/vue-quill": "^1.2.0",
    "jwt-decode": "^4.0.0",
    "pinia": "^2.1.6",
    "qrcanvas-vue": "^3.0.0",
    "vue-chartjs": "^5.2.0",
    "vue3-google-map": "^0.19.0",
    "xlsx": "^0.18.5"
  }
}

Describe the bug

Screenshot 2024-04-16 at 10 56 54 AM

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: open
  • Created 3 months ago
  • Reactions: 1
  • Comments: 15 (7 by maintainers)

Most upvoted comments

We are also facing this error. As @rankjie supposed, we also did not change the Nuxt version, but updated @nuxtjs/i18n from version 8.2.0 to 8.3.0.

Ran into this issue after upgrading from 3.11.1 to 3.11.2, building fails on both Vercel and Cloudflare pages.

Update: seems the issue comes with nuxtjs/i18n 8.3.0 not nuxt 3.11.2