Gatsby React app error Refresh Babel transform should only be enabled in development environment

Viewed 1771

Every time I install a new dependency with npm it's like cutting the read wire and hoping the bomb doesn't go off.

This error keeps coming up now:

[BABEL] React Refresh Babel transform should only be enabled in development environment. Instead, the environment is: "dev_local". If you want to override this check, pass {skipEnvCheck: true} as plugin options.

It's a Gatsby app and I can't figure out how or where to achieve {skipEnvCheck: true} I've tried various things in gatsby-node.js such as:

exports.onCreateWebpackConfig = ({ actions, plugins }) => {

  actions.setWebpackConfig({
    plugins: [
      plugins.define({
        skipEnvCheck: true,
      }),
    ],
  });
};

But it doesn't help. I have different development .env configs (e.g. this "dev_local" environment) for testing with different settings and I want to keep doing that.

Or am I just chasing ghosts here and really there is some other problem with the dependencies?

1 Answers

I ran into the same error when attempting to deploy a Gatsby app to Heroku. A frustrating rabbit hole ensued, but I eventually narrowed the fix down to using gatsby serve instead of the default gatsby develop for the start script.

In package.json:

"scripts": {
    "start": "gatsby serve --port $PORT --host 0.0.0.0",
    "build": "gatsby build",
    ...
  },
Related