Skip to content

Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined. #31649

@vbraun

Description

@vbraun

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

compiler

Is this a regression?

No

Description

Incorrect imports can cause hard-to-debug errors like

$ npx ng build b-lib
[...]
Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined.

when building libraries. Where do you even start to debug this? A bit more hand-holding would be nice.

There is a closed bug report at angular/angular#57850 where a reproducer was requested but never delivered. Well here it is!

Please provide a link to a minimal reproduction of the bug

https://github.com/vbraun/angular-repro-57850

Please provide the exception or error you saw

$ npx ng build b-lib
Building Angular Package

------------------------------------------------------------------------------
Building entry point 'b-lib'
------------------------------------------------------------------------------
✖ Compiling with Angular sources in partial compilation mode.
Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined.

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 20.3.8
Node: 22.20.0
Package Manager: npm 2.14.21
OS: linux x64
    

Angular: 20.3.9
... common, compiler, compiler-cli, core, forms
... platform-browser, router

Package                      Version
------------------------------------
@angular-devkit/architect    0.2003.8
@angular-devkit/core         20.3.8
@angular-devkit/schematics   20.3.8
@angular/build               20.3.8
@angular/cli                 20.3.8
@schematics/angular          20.3.8
ng-packagr                   20.3.0
rxjs                         7.8.2
typescript                   5.9.3
zone.js                      0.15.1

Anything else?

No response

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