I'm using 'babel-plugin-root-import' and typescript to configure absolute path.
When I'm trying to import files from root directory with import {Config} from "~/Config/Config" the "Unable to resolve module" appears.
Unable to resolve module ./src/Config/Config from D:\project\src\api\mos-api\fetchMosDataAsync.ts:
None of these files exist:
- src\api\mos-api\src\Config\Config(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
- src\api\mos-api\src\Config\Config\index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
Somehow typescript or babel concats paths but doesnt make them absolute. What am I doing wrong or maybe I'm missing some dependencies?
pacakge.json
"dependencies": {"@babel/runtime": "^7.20.7","@expo/vector-icons": "^13.0.0","@react-native-async-storage/async-storage": "~1.17.3","@react-native-community/datetimepicker": "6.1.2","@react-navigation/bottom-tabs": "^6.3.1","@react-navigation/native": "^6.0.10","@react-navigation/stack": "^6.2.2","babel": "^6.23.0","expo": "~45.0.0","expo-font": "latest","expo-linear-gradient": "~11.3.0","expo-network": "~4.2.0","expo-status-bar": "~1.3.0","expo-updates": "~0.13.4","html-entities": "^2.3.3","lodash": "^4.17.21","react": "17.0.2","react-dom": "17.0.2","react-native": "0.68.2","react-native-app-intro-slider": "^4.0.4","react-native-gesture-handler": "~2.2.1","react-native-modal-datetime-picker": "^13.1.2","react-native-reanimated": "~2.8.0","react-native-safe-area-context": "4.2.4","react-native-screens": "~3.11.1","react-native-svg": "12.3.0","react-native-web": "0.17.7" },"devDependencies": {"@babel/core": "^7.12.9","@types/lodash": "^4.14.182","@types/react": "~17.0.21","@types/react-native": "~0.66.13","babel-plugin-root-import": "^6.6.0","typescript": "^4.8.4" },
babel.config.js
module.exports = function(api) {api.cache(true);return { presets: ['babel-preset-expo'], plugins: ['react-native-reanimated/plugin', ['babel-plugin-root-import', { rootPathPrefix: '~', rootPathSuffix: 'src', } ] ],};
tsconfig.json
{"extends": "expo/tsconfig.base","compilerOptions": {"strict": true,"baseUrl": "src","rootDir": "src","paths": {"~/*": ["*"] }}