Skip to content

@angular/build:application fails with visitor is not a function because addUndefinedObjectDefaults is undefined #35267

@splincode

Description

@splincode

Current Behavior

Running an Angular app build through Nx fails with:

NX   visitor is not a function

TypeError: visitor is not a function
    at _visitJsonRecursive (.../node_modules/@angular-devkit/core/src/json/schema/visitor.js:48:19)
    at visitJson (.../node_modules/@angular-devkit/core/src/json/schema/visitor.js:86:12)
    at .../node_modules/@angular-devkit/core/src/json/schema/registry.js:319:84

The project uses:

"executor": "@angular/build:application"

Expected Behavior

Nx should be able to run the Angular application builder without crashing.

GitHub Repo

No response

Steps to Reproduce

  1. Clone git repo https://github.com/taiga-family/ng-morph
  2. Change @angular-devkit/build-angular:application to @angular/build:application in project.json
{
  "targets": {
    "build": {
      "executor": "@angular/build:application",
      "defaultConfiguration": "production",
      "configurations": {
        "production": {
          "extractLicenses": true,
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false
        }
      },
      "options": {
        "browser": "apps/demo/src/main.ts",
        "index": "apps/demo/src/index.html",
        "outputPath": "dist/apps/demo",
        "polyfills": ["apps/demo/src/polyfills.ts"],
        "styles": [
          "apps/demo/src/styles.less",
          "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less"
        ],
        "tsConfig": "apps/demo/tsconfig.app.json",
        "assets": [
          "apps/demo/src/favicon.ico",
          "apps/demo/src/assets"
        ]
      }
    }
  }
}
  1. NX_DAEMON=false NX_ADD_PLUGINS=false NX_SKIP_NX_CACHE=true npx nx run demo:build:production --verbose

Nx Report

nx: 22.6.5
@angular/build: 19.2.24
@angular/cli: 19.2.24
@angular-devkit/core: 19.2.24
Node: 22.22.2
npm  v10.9.7

Package Manager Version

npm

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

node -p "typeof require('@angular-devkit/core').schema.transforms.addUndefinedDefaults"
# function

node -p "typeof require('@angular-devkit/core').schema.transforms.addUndefinedObjectDefaults"
# undefined

At the same time, node_modules/nx/src/adapter/ngcli-adapter.js contains calls to:

registry.addPostTransform(core_1.schema.transforms.addUndefinedObjectDefaults);
registry.addPostTransform(core_1.schema.transforms.addUndefinedDefaults);

So it looks like Nx may select addUndefinedObjectDefaults for @angular/build:*, but in Angular 19.2.24 that transform is undefined, which then causes: TypeError: visitor is not a function

Workaround switching the target to:
"executor": "@angular-devkit/build-angular:application"

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions