Skip to content

Build error in zoneless SSR with polyfill #34001

Closed as not planned
Closed as not planned

Description

@jackalvrus

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

After adding a polyfill to a SSR project, the following error is reported:

✘ [ERROR] Could not resolve "zone.js/node"

    angular:polyfills-server:angular:polyfills-server:1:7:
      1 │ import 'zone.js/node';
        ╵        ~~~~~~~~~~~~~~

I tracked it down to having any polyfill with an extension that matches the regex: /\.[mc]?[jt]s$/. So .js and .ts files are affected.

Minimal Reproduction

Repro repository: https://github.com/jackalvrus/angular-polyfill-error

To manually reproduce this error, do the following:

  1. Create a new Angular 22 SSR project:
ng new polyfill-error --ssr --style sass --ai-config none
  1. Edit the project and add a file named polyfills.ts in the root directory.

  2. Edit the angular.json file and add a reference to polyfills.ts in the build options:

      "architect": {
        "build": {
          "builder": "@angular/build:application",
          "options": {
            "polyfills":["polyfills.ts"],
  1. Add polyfills.ts to files in tsconfig.app.json:
  "compilerOptions": {
    "outDir": "./out-tsc/app",
    "types": [
      "node"
    ]
  },
  "files": ["polyfills.ts"],
  1. Build the application:
npm run build

Note that an error is reported.

Exception or Error

✘ [ERROR] Could not resolve "zone.js/node"

    angular:polyfills-server:angular:polyfills-server:1:7:
      1 │ import 'zone.js/node';
        ╵        ~~~~~~~~~~~~~~

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 22.1.6
Angular           : 22.1.4
Node.js           : 26.0.0
Package Manager   : npm 11.12.1
Operating System  : win32 x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 22.1.6            │ ^22.0.2           │
│ @angular/cli              │ 22.1.6            │ ^22.0.2           │
│ @angular/common           │ 22.1.4            │ ^22.0.0           │
│ @angular/compiler         │ 22.1.4            │ ^22.0.0           │
│ @angular/compiler-cli     │ 22.1.4            │ ^22.0.0           │
│ @angular/core             │ 22.1.4            │ ^22.0.0           │
│ @angular/forms            │ 22.1.4            │ ^22.0.0           │
│ @angular/platform-browser │ 22.1.4            │ ^22.0.0           │
│ @angular/platform-server  │ 22.1.4            │ ^22.0.0           │
│ @angular/router           │ 22.1.4            │ ^22.0.0           │
│ @angular/ssr              │ 22.1.6            │ ^22.0.2           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 6.0.3             │ ~6.0.2            │
│ vitest                    │ 4.1.11            │ ^4.0.8            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else relevant?

No response

Activity

  1. added
    gemini-triaged
    on Sep 2, 2026
  2. added this to the needsTriage milestone on Sep 2, 2026
  3. alan-agius4 commented on Sep 3, 2026

    @alan-agius4
    Collaborator

    You can resolve this error by adding zone.js to your dependencies.

  4. jackalvrus commented on Sep 3, 2026

    @jackalvrus
    Author

    I've confirmed that works in my repro.

    I have to say, though, it is a brittle fix. Having that dependency when it is not actually needed invites its removal by someone who doesn't know why it's there.

  5. alan-agius4 commented on Sep 3, 2026

    @alan-agius4
    Collaborator

    That root issue is being tracked in #30689

  6. angular-automatic-lock-bot commented on Oct 21, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  7. locked and limited conversation to collaborators on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: @angular/buildgemini-triaged

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions