Build error, nuxt3 on netlify edge

I have a Nuxt 3 project with

 nitro: {
    preset: "netlify_edge",

and I am getting að build error in Netlify

12:13:13 PM: [info] [nitro] Building Nitro Server (preset: `netlify_edge`)
12:13:55 PM: <--- Last few GCs --->
12:13:55 PM: [5741:0x60912f0]    69864 ms: Mark-Compact (reduce) 2040.6 (2083.5) -> 2040.3 (2084.3) MB, 884.29 / 0.00 ms  (average mu = 0.156, current mu = 0.075) allocation failure; scavenge might not succeed
12:13:55 PM: [5741:0x60912f0]    70781 ms: Mark-Compact (reduce) 2041.3 (2084.3) -> 2040.8 (2084.8) MB, 914.43 / 0.00 ms  (average mu = 0.085, current mu = 0.003) allocation failure; scavenge might not succeed
12:13:55 PM: <--- JS stacktrace --->
12:13:55 PM: FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

This seams to be a netlify internal error.
I can build the app localy without any problems

ℹ Building Nitro Server (preset: netlify_edge)                                                                                                                                              
                      nitro 12:16:53
✔ Nitro server built                                                                                                                                                                        
                      nitro 12:17:23
  └─ .netlify/edge-functions/server/server.js (3.31 MB) (591 kB gzip)
Σ Total size: 3.31 MB (591 kB gzip)

It might seem that way, but it’s not. Nuxt (or your code) is generating a log of garbage during the build process and that goes over the limits imposed by Node.js.

You can try using the environment variable NODE_OPTIONS with the value --max-old-space-size=4096, which might or might not fix the issue. You could also try to use the solution in this thread: Netlify scheduled serverless functions not getting deployed, but I don’t think that one applies to your case.

It’s possible that the problem is specific to the Operating System being used and only happens on Netlify because the issue is specific to Ubuntu systems.

All this to say, if the above environment variable doesn’t work, there’s not much we can do here.

Thank you @hrishikesh

I found out that one package I was using was causing this problem.
I have remove this package and now everything is working :slight_smile:

@SveinnB What was the package? I’m having the same issue

in my case it was @phosphor-icons/vue
but maybe it was something wrong in my implementation.

You see the error is JavaScript heap out of memory and had something to do with how I was handling this icons.

It was working fine on my windows machine but something was wrong.
When I commented out the edge

// nitro: {
//   preset: "netlify_edge",
// }

I was able to deploy my app, but the error was still there and I saw where it was comming from.
I have re-implement my icon logic with another package
My code is better and more clean and everything is working

Good luck @andrevf


Turns out…my problem was in a composable that was trying to call a netlify edge function! As soon as I commented that out, it deployed straight away.