My application's structure is as follows:
myApplication
├── app
│ ├── api
│ ├── services
│ └── db
│ ├── index.ts
│ └── config.ts
│
├── test
│ └── helpers
│ └── setupTests.ts
│
└── tsconfig.json
and I've defined the following path aliases inside tsconfig.json:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["*"],
"@Api/*": ["app/api/*"],
"@Services/*": ["app/services/*"],
"@Db/*": ["app/db/*"],
},
"outDir": "dist",
"sourceMap": true,
"plugins": [
{ "transform": "typescript-transform-paths" }
]
}
}
using any of the path aliases in a file inside app/ works fine but when running the app with the following import inside test/helpers/setupTests.ts:
import config from '@Db/config';
I get the following error: Error: Cannot find module '@Db/config'. How can this be fixed?