0

I have an NX monorepo workspace.

I have developed a library "A" with a grouping folder to contains a bunch of different domain features "x", "y", "z" and I can build them using nx build @A/x (changing "x" with other subfolders). I have also developed a library "B" with a grouping folder as well (containing "r", "s", "t" subfolders), that in turn depends on A library.

When I try to build B library I get tons of errors of this kind:

error TS6059: File '<my-project>/libs/<A-grouping-folder>/<x-folder>/src/lib/<some-file>' is not under 'rootDir' '<my-project>/libs/<B-grouping-folder>/<r-subfolder>/src'. 'rootDir' is expected to contain all source files.

Here is the content of tsconfig.base.json file:

{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "paths": {
      "@A/x": ["libs/A/x/src/index.ts"],
      "@A/y": ["libs/A/y/src/index.ts"],
      "@A/z": ["libs/A/z/src/index.ts"],
      "@B/r": ["libs/B/r/src/index.ts"],
      "@B/s": ["libs/B/s/src/index.ts"],
      "@B/t": ["libs/B/t/src/index.ts"],
    },
    "suppressImplicitAnyIndexErrors": true,
    "strictPropertyInitialization": false,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "strictNullChecks": false,
    "noImplicitReturns": false
  },
  "exclude": ["node_modules", "tmp"]
}

In the workspace I don't have an angular.json file neither workspace.json. Both libraries have a project.json in their own "src/lib" folder.

I have read about this issue, but I'm not sure is the same. What am I doing wrong? Any idea?

smartmouse
  • 13,912
  • 34
  • 100
  • 166

1 Answers1

1

Incredibly I solved flushing node modules cache:

rm -rf node_modules/.cache

(Credits to this SO answer came out searching with different keywords).

smartmouse
  • 13,912
  • 34
  • 100
  • 166
  • Happy you've solved it. It's best practice to self mark as a duplicate when you find there's already an answer on SO. This prevents answers being spread across multiple posts – Andrew Allen Mar 22 '23 at 10:46
  • 1
    Uhm, nope. I was wrong. It worked with another library that hadn't dependencies. With the case I described above I still have the issue. I am going to delete this answer, hope you are ok with it. – smartmouse Mar 22 '23 at 19:45