Babel-plugin-module-resolver: Module not found when update package to 3.0.0 on React Native

Created on 8 Nov 2017  路  2Comments  路  Source: tleunen/babel-plugin-module-resolver

Hi @tleunen ,
I'm using ^2.7.1 before. When i tried to update the package it makes my app crash since the package cannot find the module.

Project structure:

- index.js
- .babelrc
- src
-- src/App.js (File)
-- src/Components (Folder)

Here's my .babelrc:

{
  "presets": ["react-native", "react-native-stage-0/decorator-support"],
  "env": {
    "production": {
      "plugins": ["ignite-ignore-reactotron"]
    }
  },
  "plugins": [
    ["module-resolver", {
      "root": ["./src"],
      "extensions": [".js", ".ios.js", ".android.js"],
      "alias": {
        "App": "./App",
        "Components": "./Components"
      }
    }]
  ]
}
react-native

Most helpful comment

Oh great @fatfisz ! Thank you for your information. Its working now using the 3.0.0 version. I just removed the alias and its working as i expected!

All 2 comments

Hi @adrianha, could you also provide the source code? Which package cannot be found?

I noticed that your configuration is most probably wrong: alias and root are independent, so setting "App": "./App" might not be what you meant to do:

  1. Relative paths in aliases are relative with respect to the current working dir, so if you want to alias ./src/App.js specifically, you should use "App": "./src/App" (the same for the Component)
  2. Since you already have root set as ./src, there is no need to alias something that's inside of it.

I'd strongly suggest just removing alias, but it's still a shot in the dark since I don't know what is exactly broken. Let me know if something helped!

Oh great @fatfisz ! Thank you for your information. Its working now using the 3.0.0 version. I just removed the alias and its working as i expected!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stavalfi picture stavalfi  路  3Comments

alanreidt picture alanreidt  路  3Comments

pglewis picture pglewis  路  8Comments

wlopz picture wlopz  路  7Comments

jerryslaw picture jerryslaw  路  7Comments