Skip to content

unable to find '.../.../.../src' #132

Open

Description

@Tycholiz

I have babel.config.js:

module.exports = function(api) {
  api.cache(true)

  return {
    plugins: [
      [
        'babel-plugin-root-import',
        {
          root: __dirname,
          rootPathSuffix: 'src',
          rootPathPrefix: '~/'
        }
      ]
    ],
    presets: ['module:metro-react-native-babel-preset'],
  }
}

but am having issues loading modules with ~. From src/components/organisms/Categories.js, I try to import api from '~/services/api'.

What could I possibly be missing here?

Activity

  1. chmieleski commented on Dec 11, 2019

    @chmieleski

    I'm facing the same issue.

  2. brigand commented on Dec 11, 2019

    @brigand
    Collaborator

    Without the metro-react-native preset, I get this as babel output, which looks good:

    import api from "../../services/api";

    and with it, I get this, which also appears to be correct, as long as @babel/runtime is available.

    var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");
    var _api=_interopRequireDefault(require("../../services/api"));

    Maybe something else happens when actually executed by the react-native build tools, but I'm not very familiar with it. Any more information you can provide, like the full error message?

  3. jschlachtenhaufen commented on Jun 27, 2020

    @jschlachtenhaufen

    Any updates on this? I'm getting the same issue as well

  4. nitpum commented on Jul 30, 2020

    @nitpum

    same as well

  5. zTaaso commented on Aug 18, 2020

    @zTaaso

    same here ;/

  6. enigma1 commented on Nov 13, 2020

    @enigma1

    Have you tried the static babel config and seeing the same problem. I am seeing such issues when I try it with babel.config.js and a test package but not when using the static .babelrc configuration.
    https://babeljs.io/docs/en/config-files#config-function-api
    You should check whether the the babel.config.js really takes place

  7. DracotMolver commented on Nov 19, 2020

    @DracotMolver

    I'm using .babelrc and works ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions