Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel module resolver not working with react-native

My babel module resolver is not working with React-Native (neither does intellij in VScode)

Here, Is my babel config

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'module-resolver',
      {
        root: ['./'],
        alias: {
          '@assets': './src/assets',
          '@modules': './src/modules',
          '@config': './src/config',
          '@utils': './src/utils',
        },
      },
    ],
  ],
};

And jsconfig.json

{
    "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
            "@assets": ["./assets"],
            "@modules": ["./modules"],
            "@config": ["./config"],
            "@utils": ["./utils"]
        }
    }
}

I changed import for one of my files and this is the error I get when I executed the build command from Xcode

Error: Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. Unable to resolve module ../../modules/store/components/Filters from src/utils/Router.js:

None of these files exist:

Where I imported the file like this

import Filters from '@modules/store/components/Filters';
like image 296
Cyberduck Avatar asked Dec 30 '25 22:12

Cyberduck


1 Answers

Try resetting the cache, if above suggested answers don't work

react-native start --reset-cache

This worked for me. For more info see here

like image 190
Nabeel K Avatar answered Jan 01 '26 10:01

Nabeel K