Nuxt build error: TypeError: Cannot read properties of undefined (reading 'split')

Hello :wave:! I’ve got error after build process,

  • Node version: 18
  • Nuxt 3.5.3 App
  • Build command: npm run build
  • Local building works fine
  • Site name: profound-malabi-3ad42c

Logs:

12:11:22 PM: Netlify Build                                                 
12:11:22 PM: ────────────────────────────────────────────────────────────────
12:11:22 PM: ​
12:11:22 PM: ❯ Version
12:11:22 PM:   @netlify/build 29.20.11
12:11:22 PM: ​
12:11:22 PM: ❯ Flags
12:11:22 PM:   baseRelDir: true
12:11:22 PM:   buildId: 64f3183cf0d5a7658090026f
12:11:22 PM:   deployId: 64f3183cf0d5a76580900271
12:11:22 PM: ​
12:11:22 PM: ❯ Current directory
12:11:22 PM:   /opt/build/repo
12:11:22 PM: ​
12:11:22 PM: ❯ Config file
12:11:22 PM:   /opt/build/repo/netlify.toml
12:11:22 PM: ​
12:11:22 PM: ❯ Context
12:11:22 PM:   production
12:11:22 PM: ​
12:11:22 PM: Build command from Netlify app                                
12:11:22 PM: ────────────────────────────────────────────────────────────────
12:11:22 PM: ​
12:11:22 PM: $ npm run build
12:11:23 PM: > build
12:11:23 PM: > prisma generate && nuxt build
12:11:23 PM: Prisma schema loaded from prisma/schema.prisma
12:11:23 PM: ✔ Generated Prisma Client (v5.2.0) to ./node_modules/@prisma/client in 226ms
12:11:23 PM: Start using Prisma Client in Node.js (See: https://pris.ly/d/client)
12:11:23 PM: ```
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

12:11:23 PM: or start using Prisma Client at the edge (See: What is Accelerate)
12:11:23 PM: ```
import { PrismaClient } from ‘@prisma/client/edge’
const prisma = new PrismaClient()

12:11:23 PM: See other ways of importing Prisma Client: http://pris.ly/d/importing-client
12:11:24 PM: [log] Nuxi 3.5.3
12:11:24 PM: [log] Nuxt 3.5.3 with Nitro 2.6.2
12:11:34 PM: [info] [nuxt:tailwindcss] Using default Tailwind CSS file
12:11:34 PM: [warn] Slow module `@nuxtjs/tailwindcss` took `9566.3ms` to setup.
12:11:34 PM: [warn] Slow module `@nuxthq/ui` took `9637.62ms` to setup.
12:11:35 PM: [info] Building client...
12:11:35 PM: [info] vite v4.3.9 building for production...
12:11:35 PM: [info] transforming...
12:11:47 PM: [info] ✓ 1140 modules transformed.
12:11:47 PM: [info] rendering chunks...
12:11:48 PM: [info] computing gzip size...
12:11:48 PM: [info] .nuxt/dist/client/manifest.json                        7.94 kB │ gzip:   1.00 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/Icon.6f5d80f8.css              0.07 kB │ gzip:   0.09 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/IconCSS.fe0874d9.css           0.26 kB │ gzip:   0.17 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/error-500.e798523c.css         2.02 kB │ gzip:   0.75 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/error-404.95c28eb4.css         3.70 kB │ gzip:   1.14 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/_uuid_.fc1b7233.css            6.28 kB │ gzip:   1.33 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/entry.d89df690.css           272.48 kB │ gzip:  33.16 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/auth.2084e8a3.js               0.19 kB │ gzip:   0.17 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/flow.c30151a4.js               0.20 kB │ gzip:   0.18 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/test.e3414086.js               0.21 kB │ gzip:   0.19 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/index.78bad546.js              0.23 kB │ gzip:   0.19 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/confirm.b81f8490.js            0.34 kB │ gzip:   0.27 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/logout.b6a4c02b.js             0.36 kB │ gzip:   0.27 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/login.2d0e7d27.js              0.64 kB │ gzip:   0.45 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/IconCSS.074960c7.js            0.81 kB │ gzip:   0.52 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/calculator.6a2107fa.js         0.83 kB │ gzip:   0.47 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/output.2687a26b.js             0.88 kB │ gzip:   0.50 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/if.91de9021.js                 0.99 kB │ gzip:   0.51 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/controller.314aaccb.js         1.00 kB │ gzip:   0.54 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/testnode.322e17ea.js           1.06 kB │ gzip:   0.53 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/error-component.866d4481.js    1.12 kB │ gzip:   0.61 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/chatgpt.ab3aadf1.js            1.17 kB │ gzip:   0.60 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/error-500.b884f94a.js          1.88 kB │ gzip:   0.99 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/error-404.8ed0a7fd.js          2.22 kB │ gzip:   1.15 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/Icon.28234626.js              21.19 kB │ gzip:   8.06 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/defineShortcuts.85b2a034.js   41.90 kB │ gzip:  14.05 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/dashboard.bbe449dc.js         60.91 kB │ gzip:  15.78 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/entry.f2a54b6a.js            331.89 kB │ gzip: 107.53 kB
12:11:48 PM: [info] .nuxt/dist/client/_nuxt/_uuid_.398a96fe.js           387.61 kB │ gzip: 123.12 kB
12:11:48 PM: [info] ✓ built in 12.38s
12:11:48 PM: [success] Client built in 12390ms
12:11:48 PM: [info] Building server...
12:11:48 PM: [info] vite v4.3.9 building SSR bundle for production...
12:11:48 PM: [info] transforming...
12:12:00 PM: [info] ✓ 340 modules transformed.
12:12:00 PM: [info] rendering chunks...
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/Icon-styles.946700ba.mjs              0.08 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/IconCSS-styles.e02ff92e.mjs           0.08 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-404-styles.d2a508fc.mjs         0.08 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-500-styles.0aab1d62.mjs         0.08 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/FlowContainer.vue.87c7fb75.vue        0.14 kB
12:12:00 PM: [info] .nuxt/dist/server/styles.mjs                                  0.75 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/Icon-styles-1.mjs-a085ffd6.js         0.26 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/IconCSS-styles-1.mjs-54a74734.js      0.46 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/css-styles-2.mjs-638cff50.js          0.56 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/test-4046bbef.js                      0.68 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/auth-e9454824.js                      0.85 kB │ map:   0.55 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/island-renderer-f4974276.js           1.21 kB │ map:   1.39 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/flow-59da9310.js                      1.29 kB │ map:   0.14 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/confirm-062bada8.js                   1.36 kB │ map:   0.62 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/index-2554c85e.js                     1.42 kB │ map:   0.38 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/logout-cfbefd37.js                    1.74 kB │ map:   0.51 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-component-8c5c4687.js           2.04 kB │ map:   2.71 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-500-styles-1.mjs-56d472fe.js    2.23 kB │ map:   0.12 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/IconCSS-ece810b6.js                   2.46 kB │ map:   2.00 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-dev-styles-1.mjs-8822fa55.js    2.59 kB │ map:   0.12 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/login-e5fc0f68.js                     2.63 kB │ map:   1.29 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/FlowContainer.vue-3fe2e270.js         3.04 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-500-ef392db2.js                 3.18 kB │ map:   3.78 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/FlowContainer.vue-1c97c92c.js         3.51 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-404-styles-1.mjs-0f11a32d.js    3.93 kB │ map:   0.12 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/error-404-1bd4674a.js                 4.03 kB │ map:   5.82 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/Icon-8ae1c936.js                      4.60 kB │ map:   3.70 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/index-d97a345e.js                    21.45 kB │ map: 269.26 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/dashboard-04493a23.js                27.52 kB │ map:  18.07 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/defineShortcuts-8273beaa.js          66.63 kB │ map: 127.36 kB
12:12:00 PM: [info] .nuxt/dist/server/server.mjs                                118.35 kB │ map: 213.02 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/css-styles-1.mjs-faa78de0.js        257.52 kB │ map:   0.11 kB
12:12:00 PM: [info] .nuxt/dist/server/_nuxt/_uuid_-8e314ff7.js                  335.38 kB │ map: 379.46 kB
12:12:00 PM: [info] ✓ built in 12.47s
12:12:00 PM: [success] Server built in 12483ms
12:12:00 PM: [success] [nitro] Generated public dist
12:12:00 PM: [info] [nitro] Building Nitro Server (preset: `netlify-edge`)
12:12:04 PM: node_modules/openai/core.mjs (2:3) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
12:12:04 PM: node_modules/openai/core.mjs (2:11) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
12:12:04 PM: node_modules/openai/core.mjs (16:3) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
12:12:04 PM: node_modules/openai/core.mjs (16:11) The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten
12:12:32 PM: [success] [nitro] Nitro server built
12:12:32 PM:   └─ .netlify/edge-functions/server/server.js (2.74 MB) (717 kB gzip)
12:12:32 PM: Σ Total size: 2.74 MB (717 kB gzip)
12:12:32 PM: ​
12:12:32 PM: (build.command completed in 1m 9.4s)
12:12:32 PM: ​
12:12:32 PM: Edge Functions bundling                                       
12:12:32 PM: ────────────────────────────────────────────────────────────────
12:12:32 PM: ​
12:12:32 PM: Packaging Edge Functions from .netlify/edge-functions directory:
12:12:32 PM:  - server
12:12:37 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:12:37 PM: TypeError: Cannot read properties of undefined (reading 'split')
12:12:37 PM:     at file:///opt/build/repo/.netlify/edge-functions/server/server.js:1:194335
12:12:37 PM: ​
12:12:37 PM: Bundling of edge function failed                              
12:12:37 PM: ────────────────────────────────────────────────────────────────
12:12:37 PM: ​
12:12:37 PM:   Error message
12:12:37 PM:   Could not load edge function at '/opt/build/repo/.netlify/edge-functions/server/server.js'. More on the Edge Functions API at https://ntl.fyi/edge-api.
12:12:37 PM: ​
12:12:37 PM:   Error location
12:12:37 PM:   While bundling edge function
12:12:37 PM: ​
12:12:37 PM:   Resolved config
12:12:37 PM:   build:
12:12:37 PM:     command: npm run build
12:12:37 PM:     commandOrigin: ui
12:12:37 PM:     environment:
12:12:37 PM:       - DATABASE_URL
12:12:37 PM:       - NODE_OPTIONS
12:12:37 PM:       - NUXT_OPENAI_API_KEY
12:12:37 PM:       - SUPABASE_KEY
12:12:37 PM:       - SUPABASE_URL
12:12:37 PM:     publish: /opt/build/repo/.nuxt/dist
12:12:37 PM:     publishOrigin: ui
12:12:37 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:12:37 PM: Failing build: Failed to build site
12:12:38 PM: Finished processing build request in 1m43.913s

Also tried use Netlify CLI in Windows 11 and Ubuntu 22.04 but:

â ¸ Bundling edge functions...
TypeError: Cannot read properties of undefined (reading 'split')
✖ Deploy aborted due to error while bundling edge functions

Also before that error I had errors with " JavaScript heap out of memory", but i fixed that
Thanks, and waiting for response :slight_smile:

The problem is with the Edge Function that Nuxt is generating. Please file an issue for the Nuxt team.

Thanks for the response, I will report issue to nuxt