babel-plugin-module-resolver: Not working with React Native Android project (RN 0.42)

I am working on a project with ReactNative version 0.42 for an Android app, using the Android Studio emulator. I have followed the setup instructions and also have a .babelrc file with the following:

// .babelrc
{
  "presets": ["react-native"],
  "plugins": [
    ["module-resolver", {
      "root": ["./src"],
      "alias": {
        "app": "./src/app",
        "assets": "./src/assets"
      }
    }]
  ]
}

No matter what I try, including react-native start -- -reset-cache, I still get the following:

image

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (4 by maintainers)

Most upvoted comments

I’m sorry for everyone having issues with this plugin and React Native. I’m not currently a user of React Native so I can’t really help. I’ll greatly appreciate any help improving the plugin to make it work with RN without any weird tricks.

Same issue with latest version,(“react”: “16.0.0-alpha.6”, “react-native”: “0.44.0”),alert error, checked that it keeps looking inside node_modules. “presets”: [“react-native”], “plugins”: [ [“module-resolver”, { “root”: [“./libraries”], “alias”: { “mjuicomponents”:“./libraries/components”, “mjuibase”:“./libraries/components/_base”, “mjuistyle”:“./libraries/style”, } }] ] } `

We are using react-native 0.42.0 and module resolver works here. Hierarchy:

├── common
│   ├── src
│   ├── .babelrc
├── mobile
│   ├── android
│   ├── ios
│   ├── src
│   ├── .babelrc
└── web
    ├── src
    ├── .babelrc

And web/.babelrc (referencing common sources via an npm link common):

{
  "presets": [
    "react-native"
  ],
  "plugins": [
    ["module-resolver", {
      "alias": {
        "@common": "common/src",
        "@mobile": "./src"
      }
    }]
  ],
  "sourceMaps": true
}

We seen this error and usually it’s possible to fix it by resetting the packager cache. Kill all running instances of the packager terminal window and restart it with:

yarn start -- --reset--cache

The first double dashes is not a typo.

@fatfisz I am sorry. I didn’t mean anything. Just asked out of curiosity. You are right this thread is not the place. I’d love to contribute after I learn how babel plugins work internally.