I have a project with directory "project_folder/src/..." in the project_folder contains my tsconfig.json file "project_folder/tsconfig.json", I wish to use the "@src/" for resolving modules but its not working .
Here is my tsconfig file
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@src/*": ["*"]
},
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist"]
}
This is how I am trying to import a file
import authController from "@src/controllers/AuthController";
I am not getting any Eslint error in the code but I am getting on my terminal when I try running my code.
Uncaught Error: Cannot find module '@src/controllers/AuthController'
Require stack:
- /Users/Me/Desktop/project_folder/src/routes/AuthRoutes.ts
- /Users/Me/Desktop/project_folder/src/server.ts
- /Users/Me/Desktop/project_folder/src/index.ts
I don't understand what's wrong.
I have tried changing the import method to
import authController from "@/controllers/AuthController";
and
import authController from "@controllers/AuthController";
but these didn't work, rather it only gave import errors