So I have a repository which has the code for both Angular app and Nestjs app. Folder structure looks like:
|server
----|main.ts
----|other server files...
|src
----|index.html
----|main.ts
----|other angular components
|tsconfig.app.json
|tsconfig.build.json
|package.json
My tsconfig.app.json looks like (which is being used for compiling angular app):
{
"compilerOptions": {
"outDir": "./dist",
"rootDir": ".",
"baseUrl": ".",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"target": "ES2022",
"useDefineForClassFields": false,
"module": "ES2022",
"importHelpers": true,
"removeComments": true,
"skipLibCheck": true,
"incremental": true,
"allowJs": true,
"strictPropertyInitialization": false,
"sourceMap": true,
"typeRoots": ["node_modules/@types"],
"lib": ["ES2022", "dom"],
"plugins": [
{
"name": "@angular/language-service"
}
]
},
"files": ["src/main.ts", "src/polyfills.ts"],
"exclude": ["node_modules", "dist", "server", "e2e"]
}
I have a code inside src folder, where I want to access some interfaces from server folder. I try to import using import { UserRecord } from 'server/users/interfaces/user';
But it is giving me the error: Cannot find module ‘server/users/interfaces/user’ or its corresponding type declarations.
Similarly I try to access the files within the same src folder like import { environment } from 'src/environments/environment';
, it gives me the same error.
The relative paths works fine but absolute paths not working. Please help.