Reputation: 11
I was playing around with NX monorepo NestJS + React. It has a many shared library, for sharing types and DTO-s. I have a setup for TypeORM migrations, which compiles the NestJS project using TSC, not Webpack. It has to be compiled with TSC for Typeorm to notify the database of changes. When I try to compile with TSC or Webpack I get this error:
apps/backend/src/app/users/dto/create-user.dto.ts:1:41 - error TS6059: File '/ems/shared/validation/src/index.ts' is not under 'rootDir' '/ems/apps/backend'. 'rootDir' is expected to contain all source files.
Imported via '@ems/validation' from file '/ems/apps/backend/src/app/users/dto/create-user.dto.ts'
Imported via '@ems/validation' from file '/ems/apps/backend/src/app/users/users.service.ts'
Imported via '@ems/validation' from file '/ems/apps/backend/src/app/auth/auth.service.ts'
Imported via '@ems/validation' from file '/ems/apps/backend/src/app/auth/auth.controller.ts'
Here is my root tsconfig.base.json
:
{
"compileOnSave": false,
"compilerOptions": {
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es2015",
"module": "esnext",
"lib": ["es2020", "dom"],
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"baseUrl": ".",
"paths": {
"@ems/services": ["shared/services/src/index.ts"],
"@ems/types": ["shared/types/src/index.ts"],
"@ems/ui": ["shared/ui/src/index.ts"],
"@ems/validation": ["shared/validation/src/index.ts"]
}
},
"exclude": ["node_modules", "tmp"]
}
I tried to reset NX cache, modify tsconfig files, but it doesn' twork.
I tried to remove rootDir: "."
config from tsconfig, but it doesnt help.
Upvotes: 1
Views: 239