nuxt generate FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-rc.4 Nuxt project info:
- Operating System:
Darwin
- Node Version:
v16.14.2
- Nuxt Version:
3.0.0-rc.3
- Package Manager:
yarn@1.22.17
- Builder:
vite
- User Config:
runtimeConfig
,build
,css
,buildModules
,modules
,sanity
,vite
- Runtime Modules:
@nuxtjs/sanity@1.2.2
,@vueuse/nuxt@8.6.0
- Build Modules:
@pinia/nuxt@0.1.9
,@safesoftware/safebase-vue/nuxt@0.4.0
Reproduction
yarn nuxt build
Describe the bug
when trying to generate my site i get javascript heap allocation errors.
it hangs on ℹ Initializing prerenderer
for a long time
my devops colleague said he had it running for the hour, and it finally failed (see logs).
Additional context
No response
Logs
yarn run v1.22.18
$ nuxt build
Nuxt CLI v3.0.0-rc.4 17:15:59
ℹ Running with Sanity project XXXXXX (production). @nuxtjs/sanity 17:16:14
ℹ Vite client warmed up in 77349ms 17:17:46
WARN 17:18:46
(!) 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.
ℹ Client built in 137160ms 17:18:46
ℹ Building server... 17:18:46
WARN @fortawesome/fontawesome-pro doesn't appear to be written in CJS, but also doesn't appear to be a valid ES module (i.e. it doesn't have "type": "module" or an .mjs extension for the entry point). Please contact the package author to fix.
✔ Server built in 65079ms 17:19:51
✔ Generated public .output/public nitro 17:19:54
start Building server... nitro 17:19:54
WARN rollup-plugin-inject: failed to parse /code/safecom-fmeuc/.nuxt/dist/server/server.mjs. Consider restricting the plugin to particular files via options.include
ERROR Rollup error: Identifier 'useRuntimeConfig' has already been declared (Note that you need plugins to import files that are not JavaScript) nitro 18:16:01
ERROR Identifier 'useRuntimeConfig' has already been declared (Note that you need plugins to import files that are not JavaScript) 18:16:01
at error (node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at Module.error (node_modules/rollup/dist/es/shared/rollup.js:12422:16)
at Module.tryParse (node_modules/rollup/dist/es/shared/rollup.js:12799:25)
at Module.setSource (node_modules/rollup/dist/es/shared/rollup.js:12704:24)
at ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/rollup.js:22178:20)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Issue Analytics
- State:
- Created a year ago
- Reactions:5
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Nuxt generate FATAL ERROR: Ineffective mark-compacts ...
vue. js - Nuxt generate FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory - Stack ...
Read more >Common memory leak issues in nuxt.js
FATAL ERROR : Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory.
Read more >Nuxt generate FATAL ERROR: Ineffective mark-compacts ...
Coding example for the question Nuxt generate FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory-nuxt.js.
Read more >Allocation Failed - Javascript Heap Out Of Memory ( Nuxt Js)
I tried using v2.0.0 with my nextjs sample project and got a javascript error: near heap limit Allocation failed - JavaScript heap out...
Read more >JavaScript heap out of memory - Snyk Support
This generally occurs on larger projects where the default amount of memory allocated by Node (1.5gb) is insufficient to complete the command successfully....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
However, I still cannot reproduce this with the updated reproduction.
But, I think we can tentatively suggest that this might be an issue with rollup, which takes a fair amount of memory when compiling. In the original issue reporter’s case, it’s not vite but the nitro rollup build, but still this issue is relevant: https://github.com/vitejs/vite/issues/2433#issuecomment-1262301699.
You might try disabling sourcemaps:
@danielroe https://stackblitz.com/edit/github-fsjrqu?file=nuxt.config.ts
seems like not having a
pages/index.vue
fails thenpm run generate
commandso the error is different than on my local repo… but maybe because the repo is bigger it just takes longer and therefor uses more memory trying to build