Skip to content

Cannot build - "undefined" is not valid JSON [plugin angular-less] - with sourcemaps enabled angular.json #29719

@thaoula

Description

@thaoula

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

19.1.x

Description

Hi Team,

Just tried upgrading to Angular 19.2.0 and have hit an issue when attempting to build our large Angular project.

I keep getting the following error -
"undefined" is not valid JSON [plugin angular-less]

We have 5 different projects in our Angular.json and 3 of them build and 2 present this error. The exact same error repeats 33 times for 1 of the projects and only 2 time for another project.

If i disable sourcemaps in angular.json I can build.

Minimal Reproduction

  1. ng update @angular/cli @angular/core
  2. ng build

Exception or Error

✘ [ERROR] "undefined" is not valid JSON [plugin angular-less]

    node_modules/@angular/build/src/tools/esbuild/stylesheets/less-language.js:189:21:
      189 │     const map = JSON.parse(sourceMap);
          ╵                      ^

    at JSON.parse (<anonymous>)
    at sourceMapToUrlComment (/Users/thaoula/projects/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/stylesheets/less-language.js:189:22)
    at compileString (/Users/thaoula/projects/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/stylesheets/less-language.js:134:54)
    at async processStylesheet (/Users/thaoula/projects/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js:180:18)

  This error came from the "onLoad" callback registered here:

    node_modules/@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js:125:22:
      125 │                 build.onLoad({ filter: language.fileFilter, names...
          ╵                       ~~~~~~

    at setup (/Users/thaoula/projects/jms-platform/jms-web/node_modules/@angular/build/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js:125:23)
    at handlePlugins (/Users/thaoula/projects/jms-platform/jms-web/node_modules/esbuild/lib/main.js:1151:21)

Your Environment

Angular CLI: 19.2.0
Node: 20.18.1
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: 19.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.0
@angular-devkit/build-angular   19.2.0
@angular-devkit/core            19.2.0
@angular-devkit/schematics      19.2.0
@angular/cdk                    19.2.1
@angular/cdk-experimental       19.2.1
@schematics/angular             19.2.0
rxjs                            7.8.2
typescript                      5.7.3
zone.js                         0.15.0

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions