'Typescript Node: Error: Cannot find module '@/config'

So it seems like I am missing something. I am trying to add relative imports with typescript, express.js into my project using @ to represent src but I keep getting the error above.

{
  "compilerOptions": {

    /* Language and Environment */
    "target": "es2016",                                  
    /* Modules */
    "module": "commonjs",                                
    "checkJs": true,                                 
    "outDir": "./dist,
    "esModuleInterop": true,                             
    // "preserveSymlinks": true,                         
    "forceConsistentCasingInFileNames": true,            
    /* Type Checking */
    "strict": true,                                      
    "alwaysStrict": true,                            
    "skipLibCheck": true                                
  },
  "include": [
    "src/**/*",
    "src/**/*.json",
    "src/**/*.js",
  ],
  "exclude": [
    "src/**/*.spec.ts",
    "src/**/*.test.ts",
    "node_modules"


  ],
  "extends": "./tsconfig.paths.json"
}


tsconfig.paths.json

{
    "compilerOptions": {
      "baseUrl": ".",
      "paths": {
        "@/*": ["./src/*"]
      }
    }
  }
 "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev:server": "nodemon --watch './**/*.ts' --exec ts-node ./src/app.ts"
  },

and this is the point within the project that I am importing the config file as the index.ts in the config folder

import express from 'express'
import config from '@/config'

const app = express()
app.listen(config.PORT, () =>{
    console.log('SERVER STARTED ')
})

The typescript isn't the issue, it is the node app itself that crashes



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source