I'm trying to use babel-plugin-module-resolver in a react-native app. When I use plugin config like this in babel.config.js
it works perfectly.
plugins: [
[
'module-resolver',
{
extensions: ['.ios.js', '.android.js', '.js', '.json'],
alias: {
utils: './src/utils',
},
},
],
],
But the problem is that I have to write ./src in every alias path. So I tried to use root
option. Here's the code I tried
plugins: [
[
'module-resolver',
{
root: './src', // I also tried ['./src']
extensions: ['.ios.js', '.android.js', '.js', '.json'],
alias: {
utils: 'utils', // already tried '/utils' and './utils'
},
},
],
],
But that didn't worked for me and I get this error:
error: Error: Unable to resolve module '../../../utils/Themes' from 'src/components/shared/Container.js':
So what's the correct way to use root
option?