Using Relay Modern & Expo with babel-plugin-relay

I’m trying to get a project up and running with Relay Modern, and get the following error

The package at "node_modules/babel-plugin-relay/lib/getDocumentName.js" attempted to import the Node standard library module "path". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq.html#can-i-use-nodejs-packages-with-expo

I’ve read the docs at https://docs.expo.io/versions/latest/introduction/faq#can-i-use-expo-with-relay , and my .babelrc looks like this

{
  "presets": [
    "babel-preset-expo",
    { "plugins": ["./node_modules/babel-plugin-relay"] }
  ],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

I’ve gone through various docs on the Relay site and elsewhere, and nothing gets around this. Is there a particular Relay plugin, which is not babel-plugin-relay, which avoids using Node standard library, which I should be using?

1 Like

it’s strange that code that is attempting to require the path module is making it into the bundle that is loaded by react-native. can you inspect the bundle and see where that’s coming from? the error message you’re getting is a more helpful version (usually) of “Unable to resolve “path” from …” when you try to do const path = require('path') and path is not available in your project (https://github.com/expo/expo-cli/blob/c8b9872eba820af592c541c0d43d96bd446a0df3/packages/xdl/src/logs/PackagerLogsStream.js#L398-L418)

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.