This project reproduces the following build error in Angular SSR:
✘ [ERROR] Could not resolve "zone.js/node"
angular:polyfills-server:angular:polyfills-server:1:7:
1 │ import 'zone.js/node';
╵ ~~~~~~~~~~~~~~
This issue was reproduced in Angular 22.
To reproduce this error, do the following:
- Create a new Angular 22 SSR project:
ng new polyfill-error --ssr --style sass --ai-config none-
Edit the project and add a file named
polyfills.tsin the root directory. -
Edit the
angular.jsonfile and add a reference topolyfills.tsin the build options:
"architect": {
"build": {
"builder": "@angular/build:application",
"options": {
"polyfills":["polyfills.ts"],- Add
polyfills.tstofilesintsconfig.app.json:
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [
"node"
]
},
"files": ["polyfills.ts"],- Build the application:
npm run buildNote that an error is reported.