I’ve got a NestJS app with compilerOptions.paths
specified as follows:
"paths": {
"@core/interceptors": [
"core/interceptors/index.ts"
]
}
Then I import it like this in controllers:
import { ResponseValidationInterceptor } from '@core/interceptors';
There are no errors in IDE, but when I try to serve the app, I got prompted with following error:
Error: Cannot find module '../../core/interceptors/index.ts'
When I check the dist/
folder, I can see in the controller
file, the path to import the interceptor looks const interceptors_1 = require("../../core/interceptors/index.ts");
I tried using module-alias
npm package, by specyfing addAlias('@core/interceptors', 'core/interceptors/index.js');
after list of imports in my main.ts
file, but it doesn’t have any effect.
How can I adjust my tsconfing.json
or tsconfig.build.json
to properly compile this path?