Question:
I’m working on a TypeScript project and using path aliases for cleaner import statements. However, I am facing issues when building my project where the TypeScript compiler fails to resolve these path aliases. I have set up my tsconfig.json
with path aliases, but the build process does not recognize them.
Environment:
- Operating System: Debian 64-bit
- Node: 20.12.0
- TypeScript: 5.5.4
Configuration Details:
- tsconfig.json Setup:
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"outDir": "./dist",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"]
}
- Build Script:
I use the following build script in package.json
:
"scripts": {
"build": "tsc"
}
Expected Output:
I expect the TypeScript compiler to correctly resolve path aliases during the build process, resulting in a successful compilation of my code.
Additional Information:
I have tried using npx tsconfig-paths
, but I encounter issues where it cannot determine the executable to run.
Could someone provide guidance on resolving this issue with path alias resolution during the build process in TypeScript? Any help would be greatly appreciated. Thank you!