Search code examples
babeljsrelayjsrelay

Babel : error when trying to use relay preset 'Couldn't find preset "relay" relative to directory'


I'm trying to install relay in my project using the official docs.

I installed relay using:

yarn add react react-dom react-relay
yarn add --dev babel-plugin-relay graphql

My .babelrc file looks like this:

{
  "presets": [
    "relay", "env", "react"
  ]
}

When running webpack go this error:

ERROR in ./js/app.js
Module build failed: Error: Couldn't find preset "relay" relative to directory "/Users/nicolas/projects/grocery_umbrella/apps/grocery_web/assets"

What could be the problem?


Solution

  • babel-plugin-relay is a plugin, not a preset, so you need

    {
      "presets": [
        "env", "react"
      ],
      "plugins": [
        "relay"
      ]
    }