angulartypescriptnrwl-nx

NX Angular project fails build with error TS6059: File is not under 'rootDir'


I have an angular project inside an NX monorepo.

when I serve the app everything works, however when I build for production I get a lot of errors like the following:

libs/data/persistance/firebase/src/lib/data-persistance-firebase.module.ts:1:1 - 
error TS6059: File 
'C:/Users/jorda/source/repos/ng-firebase/firebase-demo/libs/data/persistance/firebase/src/lib/data-persistance-firebase.module.ngtypecheck.ts' 
is not under 'rootDir' 
'C:\Users\jorda\source\repos\ng-firebase\firebase-demo\libs\data\state\auth\src'. 
'rootDir' is expected to contain all source files.

I have reviewed the paths config of the workspace root tsconfig.base.json:

    "paths": {
      "@fba/data/persistance/firebase": ["libs/data/persistance/firebase/src/index.ts"],
      "@fba/data/state/auth": ["libs/data/state/auth/src/index.ts"],
      "@fba/feature/auth": ["libs/feature/auth/src/index.ts"],
      "@fba/feature/feature-one": ["libs/feature/feature-one/src/index.ts"],
      "@fba/feature/feature-two": ["libs/feature/feature-two/src/index.ts"]
    },

but everything looks good here

As far as I can see all imports use "@fba/..." syntax when importing from another lib.

I am not sure how to debug this.

The libs all have build targets and tsconfig.ts,ng-package.json, and project.json files.

I tried:

  1. removing "rootDir": "." from tsconfig.base as per this
  2. removing the .cache folder from node_modules
  3. remove and reinstall node_modules
  4. update npm packages to most recent version
  5. make sure I did not duplicate a "paths" variable in another lib's tsconfig
  6. make sure there is no cirular dep between @fba/data/persistance/firebase and fba/data/state/auth

Can someone help me understand what is going on here?


Solution

  • For me it turned out to be an issue when I migrated from an angular project to a nx monorepo. The migration failed and so the config files were not properly formed, mostly the tsconfig and project.json files.

    I removed and re added the NX libs and that fixed the issues for me. It was a lot of work but it was the solution.