1

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"
                ]
            }
        }
    }
}
Muljayan
  • 3,588
  • 10
  • 30
  • 54
  • See my answer [here](https://stackoverflow.com/a/63745316/6676781). Moreover, if you want to take a look at my project (more or less same structure) see [here](https://github.com/GiovanniZotta/fog_cloud_project/tree/main/graphmarket). – Carlo Corradini Jun 21 '21 at 09:15

0 Answers0