I have read through a bunch of posts and documentation but cant seem to get my TS Node Express Server to use absolute paths for imports.
Here is my project structure - src
is the Typescript code and dist
is the output directory.
.
├── dist
├── Dockerfile
├── node_modules
├── package.json
├── package-lock.json
├── public
├── readme.md
├── src
├── tsconfig.json
└── @types
Also here is my current tsconfig.json file:
{
"compilerOptions": {
"target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"outDir": "./dist" /* Redirect output structure to the directory. */,
"strict": true /* Enable all strict type-checking options. */,
"baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
"paths": { "./src/*": ["./src/*"]}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"typeRoots": ["@types", "@types/custom.d.ts"], /* List of folders to include type definitions from. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": [
"@types/custom.d.ts",
"src"
],
"exclude": ["node_modules"]
}