ReferenceError: global is not defined

I am trying to deploy an Angular SSR app. The build fails at “Building > Edge Functions bundling” with the error: ReferenceError: global is not defined. Why?

Some facts:

  • I have an Angular SSR app that works.
  • I am using the Hybrid Rendering feature with only 1 path that is server rendered
  • When I “remove” the “Runtime” deployment settings, it deploys! and is usable
  • When it deploys without the Angular runtime, SSR does not work as it does not deploy the edge function
  • When I deploy with the Angular runtime I get the below error
  • Node v20.18.1
  • Angular v19.0.3
  • @netlify/angular-runtime v2.2.1
  • App name is jm-angular-app
  • I do not use global anywhere in the app

Here is the full stacktrace:

ReferenceError: global is not defined
    at node_modules/graceful-fs/graceful-fs.js (file:///opt/build/repo/dist/jobs-marketplace/server/server.mjs:492:7)
    at __require2 (file:///opt/build/repo/dist/jobs-marketplace/server/chunk-WXP5WYDQ.mjs:45:50)
    at node_modules/fs-extra/lib/fs/index.js (file:///opt/build/repo/dist/jobs-marketplace/server/server.mjs:787:15)
    at __require2 (file:///opt/build/repo/dist/jobs-marketplace/server/chunk-WXP5WYDQ.mjs:45:50)
    at node_modules/fs-extra/lib/index.js (file:///opt/build/repo/dist/jobs-marketplace/server/server.mjs:2183:176)
    at __require2 (file:///opt/build/repo/dist/jobs-marketplace/server/chunk-WXP5WYDQ.mjs:45:50)
    at node_modules/@netlify/angular-runtime/src/helpers/getAngularJson.js (file:///opt/build/repo/dist/jobs-marketplace/server/server.mjs:2196:9)
    at __require2 (file:///opt/build/repo/dist/jobs-marketplace/server/chunk-WXP5WYDQ.mjs:45:50)
    at node_modules/@netlify/angular-runtime/src/helpers/fixOutputDir.js (file:///opt/build/repo/dist/jobs-marketplace/server/server.mjs:2566:26)
    at __require2 (file:///opt/build/repo/dist/jobs-marketplace/server/chunk-WXP5WYDQ.mjs:45:50)

Here is my server.ts

// From a forum post.  It didnt work.
// if (typeof global === undefined) {
//   globalThis.global = globalThis
// }

import { CommonEngine } from '@angular/ssr/node'
import { render } from '@netlify/angular-runtime'

const commonEngine = new CommonEngine()

export async function netlifyCommonEngineHandler(request: Request, context: any): Promise<Response> {
  return await render(commonEngine)
}

Here is my netlfiy.toml

[build]
  command = "yarn build:develop"
  publish = "dist/jobs-marketplace/browser"
  • I think the build logs are public, but at the time of writing I can’t seem to find that setting again.
  • I searched the forums and looked at the guide/faqs and did not find a similar issue

Help?