angular: Ivy compiling error: Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined.

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

No response

Description

when run ng build on shared library ivy compiler gave generic error

Cannot destructure property ‘pos’ of ‘file.referencedFiles[index]’ as it is undefined.

Minimal Reproduction

ng build shared log.txt

Exception or Error

enable "traceResolution" on tsConfig.json have log output attach on log.txt

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 18.2.4
Node: 20.15.1
Package Manager: npm 10.8.3
OS: win32 x64

Angular: 18.2.4
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, localize, material
... platform-browser, platform-browser-dynamic, platform-server
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.4
@angular-devkit/build-angular   18.2.4
@angular-devkit/core            18.2.4
@angular-devkit/schematics      18.2.4
@schematics/angular             18.2.4
ng-packagr                      18.2.1
rxjs                            7.8.1
typescript                      5.5.4
webpack                         5.94.0
zone.js                         0.14.10

Anything else relevant?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 10
  • Comments: 16 (3 by maintainers)

Most upvoted comments

I also got this issue because I put “composite: true” in my nx root tsconfig.json because otherwise I get linter errors all over the place telling me that my referenced tsconfig must have “composite: true”. But removing it again fixed the issue. I’m so confused about how I’m supposed to be using composite: true so that I can satisfy everything.

I encountered the same issue, but I found the reason: I had a workspace with two projects: An application project and a library project. I was using a component from the application inside the library. While I could serve the application without issue, the error appeared when I tried to build the library.

In some cases, especially when working with an Nx library, you may want to structure components in separate folders within the library. To import files across different folders, it may be necessary to add an ng-package.json file in each folder.

In case this helps anyone: I had the same issue, and it turned out to be caused by referencing a file outside of my library’s directory(src/lib). Once I moved the file into the library and updated the reference paths, the issue was resolved.

Hi everyone, we found the issue. Was on tsconfig.json, with double relative paths with similar paths. commented worked just fine

image

For me the issue dissapeared after removing "composite": true in the compiler options of tsconfig.app.json file