I know how to resolve absolute path using React Native locally, my problem is using snack.
I’m using snack expo dev: https://snack.expo.dev/@danilobatistaqueiroz/water-tracker
If I try to import a module using absolute path, I get an error because the path has duplicated src folder: Unable to resolve module://src/src/libraries/storage.js
//src/components/insights/insights.js
import {saveData, getData} from '/src/libraries/storage';
How to resolve the absolute path correctly?
It seems my babel config isn’t working:
//babel.config.js
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: [
[
"babel-plugin-root-import",
{
"rootPathPrefix": "@",
"rootPathSuffix": "src",
}
],
[
'module-resolver',
{
root: ["./"],
alias: {
assets: './assets',
components: './src/components',
libraries: './src/libraries'
},
},
],
],
};
};
I tried using the imports below and didn’t work:
import {saveData, getData} from '@/libraries/storage';
import {saveData, getData} from 'libraries/storage';