The issue at hand:
I am facing a challenge with relative module paths and have attempted to resolve it by configuring the baseUrl
setting in my tsconfig.json file. Despite my efforts, I keep receiving an error indicating that the module cannot be found. I am unsure of what might be causing this issue. Is there something crucial that I am overlooking or any additional steps necessary besides specifying the baseUrl
as my src
directory in the tsconfig?
https://i.stack.imgur.com/QjwUg.png
Interestingly enough, when I attempt to import the module, intellisense displays the folder for the module ('utils'): https://i.stack.imgur.com/6AxcD.png
Overview of my project structure:
root
- dist
- src
- MyProject.ts
- utils
- IntHelper.ts
- tsconfig.json
File: MyProject.ts
import { IntHelper } from 'utils/IntHelper';
File: IntHelper.ts
export module IntHelper {
export const xy: string = 'Test';
export function crossSum(int: number) {
return int; // Just a placeholder.
}
}
Tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist",
"baseUrl": "./src",
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
}
},
"include": [
"src/**/*"
]
}