I am aware that this question has been asked multiple times however after trying most of them I am unable to make it work for my use case. I am building simple API with Typescript and Node. I have all my code residing in the src
folder from the root.
To avoid those annoying ../../
i have configured absolute paths in my tsconfig.json
with the following declarations.
"baseUrl": "./",
"paths": {
"*":[
"./src/*"
]
},
So lets say i have a config.ts file, I should be able to access it from 'src/controllers/tickets.controllers.ts' by just calling import config from 'config'
This does not work.
Additionally in my .eslintrc.json
file i have added the following declarations as mentioned in many any answers related to this question.
{
"env": {
"es2021": true,
"node": true
},
"extends": [
"airbnb-base"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"ts": "never"
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".ts"
]
}
}
}
}