Skip to content

tsconfig.json "paths": {} resolution not working #28388

@MPalix86

Description

@MPalix86

Command

serve

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

15

Description

In our company, we have a large Angular project that consists of a src directory and various local libraries. Before upgrading from Angular 15 to Angular 18 with the new application builder, we used paths configurations in tsconfig.json, combined with baseUrl and a Webpack plugin, to directly reference the public API from our projects folder (where the libraries are located). This setup allowed Angular to trigger a rebuild whenever we made changes in a library.

Before migrating our main app to Angular 18, I tested this setup with a new Angular 18 project containing a single library. I found that the paths configuration should be supported out of the box with Angular 18 without needing additional changes.

However, after the migration, I haven’t been able to get Angular (or esbuild) to recognize the paths defined in the tsconfig.json file. It seems that Angular is reading the compiled versions of the libraries inside node_modules, ignoring the paths configuration in tsconfig.json. I've tried various configurations, including changing moduleResolution to bundler, but none of these have resolved the issue. While VS Code's IntelliSense correctly recognizes the paths defined in tsconfig.json and does not show errors, running ng serve results in a series of errors:


TS2307: Cannot find module '...' or its corresponding type declarations.

Minimal Reproduction

Reproduction

Exception or Error

TS2307: Cannot find module '....' or its corresponding type declarations. [plugin angular-compiler]

Your Environment

Angular CLI: 18.2.3
Node: 18.19.1
Package Manager: npm 10.2.4
OS: win32 x64

Angular: 18.2.3
... animations, cdk, cli, common, compiler, compiler-cli, core
... elements, forms, language-service, localize
... platform-browser, platform-browser-dynamic, router
... service-worker

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1802.3
@angular-devkit/build-angular      18.2.3
@angular-devkit/core               18.2.3
@angular-devkit/schematics         18.2.3
@angular/material                  17.3.10
@angular/material-moment-adapter   17.3.10
@schematics/angular                18.2.3
ng-packagr                         18.2.1
rxjs                               7.8.1
typescript                         5.5.4
zone.js                            0.14.10

Anything else relevant?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions