Skip to content

@angular/build: build fails on Linux (Node 22) with TypeError: Cannot read properties of undefined (reading 'getStatus') during angular-compiler` initialization #33050

@petereijgermans11

Description

@petereijgermans11

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

Yes

Description

We maintain patch-package patches for @angular/build (version-specific filenames, e.g. patches/@angular+build+21.2.7.patch) that adjust the implementation in:
node_modules/@angular/build/src/tools/angular/compilation/angular-compilation.js
— specifically the loadCompilerCli path — to use an asynchronous/dynamic import('@angular/compiler-cli') (or equivalent) instead of a synchronous require of a package that is effectively treated as ESM in this Node version, which avoids the ESM ModuleLoader / getModuleJobForRequire error path on Linux.
This matches the internal README guidance we use for “ESM load fix for @angular/compiler-cli”.

Suggested area / labels

  • @angular/build / esbuild application builder
  • angular-compiler plugin
  • Node.js 22 + ESM / compiler-cli loading

Contact

my email: p.eijgermans11@gmail.com.
name: Peter Eijgermans

Please provide a link to a minimal reproduction of the bug

Starting: Build application

Task : npm
Description : Install and publish npm packages, or run an npm command.
Supports npmjs.com and authenticated registries like Azure Artifacts.
Version : 1.270.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/package/npm

==============================================================================

/opt/hostedtoolcache/node/22.13.0/x64/bin/npm config list

; "user" config from /home/vsts/work/1/npm/538291.npmrc
; //pkgs.dev.azure.com/ProRail/Spoorpartners/_packaging/spoorpartners-npm/npm/registry/:_authToken = (protected)
; overridden by project

; "project" config from /home/vsts/work/1/s/emplacement-viewer/.npmrc
@ProRail:registry = "https://pkgs.dev.azure.com/ProRail/Spoorpartners/_packaging/spoorpartners-npm/npm/registry/"
//pkgs.dev.azure.com/ProRail/Spoorpartners/_packaging/spoorpartners-npm/npm/registry/:_authToken = (protected)
registry = "https://registry.npmjs.org/"

; "env" config from environment
cache = "/home/vsts/work/1/.npm"
userconfig = "/home/vsts/work/1/npm/538291.npmrc"

; node bin location = /opt/hostedtoolcache/node/22.13.0/x64/bin/node
; node version = v22.13.0
; npm version = 10.9.2
; npm local prefix = /home/vsts/work/1/s/emplacement-viewer
; cwd = /home/vsts/work/1/s/emplacement-viewer
; HOME = /home/vsts
; Run npm config ls -l to show all defaults.

==============================================================================

/opt/hostedtoolcache/node/22.13.0/x64/bin/npm run build --releaseversion=native-federation-SNAPSHOT

✘ [ERROR] Angular compilation initialization failed. [plugin angular-compiler]

TypeError: Cannot read properties of undefined (reading 'getStatus')
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:363:22)
at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
at ModuleLoader.getModuleJobForRequire (node:internal/modules/esm/loader:413:11)
at new ModuleJobSync (node:internal/modules/esm/module_job:341:34)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:326:11)
at loadESMFromCJS (node:internal/modules/cjs/loader:1411:24)

emplacement-viewer@0.0.0 prebuild
sh build/create_version_envfile.sh $npm_config_releaseversion

resulting file location: src/environments/version.ts

emplacement-viewer@0.0.0 build
ng build --configuration production

INFO Building federation artefacts
INFO Preparing shared npm packages for the platform browser-shared
NOTE This only needs to be done once, as results are cached
NOTE Skip packages you don't want to share in your federation config
❯ Building...
✔ Building...
Application bundle generation failed. [14.344 seconds] - 2026-04-24T11:05:56.571Z

##[warning]Couldn't find a debug log in the cache or working directory
##[error]Error: Npm failed with return code: 1
Finishing: Build application

the environment

on linux environment !

"name": "@angular/build",
"version": "21.2.8",

"name": "@angular/compiler-cli",
"version": "21.2.9",

"name": "@angular/core",
"version": "21.2.9",

patch:

static #angularCompilerCliModule;
static #typescriptModule;
static async loadCompilerCli() {
    AngularCompilation.#angularCompilerCliModule ??= await Promise.resolve().then(() => __importStar(require('@angular/compiler-cli')));
    if (!AngularCompilation.#angularCompilerCliModule) {
        const mod = await import('@angular/compiler-cli');
        AngularCompilation.#angularCompilerCliModule = { __esModule: true, ...mod };
    }
    return AngularCompilation.#angularCompilerCliModule;
}
static async loadTypescript() {

package.json

{
"name": "emplacement-viewer",
"version": "0.0.0",
"scripts": {
"postinstall": "patch-package",
"ng": "ng",
"start": "npm run create_version_file && ng serve",
"oidc": "ng serve --port 4200 --configuration oidc",
"jumphost": "ng serve --configuration jumphost",
"starte2e": "npm run create_version_file && ng run emplacement-viewer:serve-cypress:cypress",
"starte2e:dev": "npm run create_version_file && ng run emplacement-viewer:serve-cypress:development",
"prebuild": "sh build/create_version_envfile.sh $npm_config_releaseversion",
"build": "ng build --configuration production",
"postbuild": "npm run extract-css && cat dist/emplacement-viewer/.js > dist/emplacement-viewer/app-ev.js",
"extract-css": "cat dist/emplacement-viewer/styles.css | node build/wrap-css.js > dist/emplacement-viewer/styles.js",
"lint": "ng lint",
"e2e": "ng e2e",
"install_local_dependencies": "npm install ../emplacement-renderer/dist/emplacement-renderer/emplacement-renderer-1.0.0.tgz",
"cy:run": "cypress run",
"cy:open": "cypress open",
"cy:start": "start-server-and-test starte2e http-get://localhost:4201 cy:open",
"cy:verify": "npx cypress verify",
"e2e:cy": "npm run pretest && start-server-and-test starte2e http-get://localhost:4201 cy:run",
"clean:reports": "rm -R -f cypress/reports && mkdir cypress/reports && mkdir cypress/reports/mochareports",
"pretest": "npm run clean:reports",
"scripts": "cypress run",
"combine-reports": "mochawesome-merge cypress/reports/mocha/
.json > cypress/reports/mochareports/report.json",
"generate-report": "marge cypress/reports/mochareports/report.json -f report -o cypress/reports/mochareports",
"posttest": "npm run combine-reports && npm run generate-report",
"test": "npm run scripts || npm run posttest",
"create_version_file": "sh build/create_version_envfile.sh",
"unit-test": "ng test --code-coverage",
"unit-test:ci": "npm run create_version_file && ng test --browsers=ChromeHeadlessCI --no-watch --no-progress --code-coverage"
},
"private": true,
"engines": {
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
},
"dependencies": {
"@angular-architects/native-federation": "^21.2.3",
"@angular/animations": "^21.2.4",
"@angular/cdk": "^21.2.3",
"@angular/common": "^21.2.4",
"@angular/compiler": "^21.2.4",
"@angular/core": "^21.2.4",
"@angular/forms": "^21.2.4",
"@angular/material": "21.2.3",
"@angular/platform-browser": "^21.2.4",
"@angular/platform-browser-dynamic": "^21.2.4",
"@azure/msal-angular": "^3.0.11",
"@azure/msal-browser": "^3.7.1",
"@opentelemetry/api": "^1.9.0",
"@prorail/opentelemetry-setup": "^1.0.6",
"@prorail/shared-services": "^1.0.4",
"@stomp/rx-stomp": "^2.3.0",
"@stomp/stompjs": "^7.3.0",
"emplacement-renderer": "file:../emplacement-renderer/dist/emplacement-renderer/emplacement-renderer-1.0.0.tgz",
"hammerjs": "^2.0.8",
"material-design-icons": "^3.0.1",
"rxjs": "~7.8.2",
"svg-pan-zoom": "^3.6.1",
"tslib": "^2.8.1",
"uuid": "^9.0.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular/build": "^21.2.2",
"@angular/cli": "~21.2.2",
"@angular/compiler-cli": "^21.2.4",
"@angular/router": "^21.2.4",
"@types/jasmine": "~6.0.0",
"@types/jasminewd2": "~2.0.10",
"cypress": "^15.12.0",
"cypress-multi-reporters": "^2.0.5",
"cypress-wait-until": "^3.0.2",
"es-module-shims": "^1.5.12",
"jasmine-core": "~6.1.0",
"karma": "^6.4.4",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.1",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.2.0",
"mocha": "^10.2.0",
"mochawesome": "^7.1.3",
"mochawesome-merge": "^4.3.0",
"mochawesome-report-generator": "^6.2.0",
"patch-package": "^8.0.1",
"start-server-and-test": "^2.1.5",
"ts-node": "~10.9.1",
"typescript": "~5.9.3"
},
"optionalDependencies": {
"@esbuild/linux-x64": "0.27.3",
"@lmdb/lmdb-linux-x64": "3.5.1",
"@lmdb/lmdb-win32-x64": "3.5.1",
"@napi-rs/magic-string-linux-x64-gnu": "0.3.4",
"@napi-rs/nice-linux-x64-gnu": "1.1.1",
"@oxc-parser/binding-linux-x64-gnu": "0.8.0",
"@rolldown/binding-linux-x64-gnu": "1.0.0-rc.4",
"@rollup/rollup-linux-x64-gnu": "4.60.1"
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions