Skip to content

Instantly share code, notes, and snippets.

@DZuz14
Last active January 19, 2020 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DZuz14/5cd84aa5f5fb720f0edb0458feaf7592 to your computer and use it in GitHub Desktop.
Save DZuz14/5cd84aa5f5fb720f0edb0458feaf7592 to your computer and use it in GitHub Desktop.
Gatsby Config Suggestions

Gatsby Config Suggestions

Here are the following errors I receive on my Windows 10 machine using gatsby ^2.18.12. At the bottom of the file, I've included the specs of my computer for reference. I decided to remove stack trace info, as it really doesn't matter at the moment.

Top Level Keys

If a top level key is misspelled or a an invalid key is added.

  • Change "plugins" to "plugin".
{
  siteMetadata: {
    title: `Gatsby Default Starter`,
  },
  plugin: [
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
  ],
}
  • Add random key
{
  siteMetadata: {
    title: `Gatsby Default Starter`,
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
  ],
  roflWaffle: true
}

Error

UNHANDLED REJECTION Reducers may not dispatch actions.
Error: Reducers may not dispatch actions.

Plugin Object

A plugin can be listed just as a string, or can be added as an object. Misspelling a key results in an error. Not sure why gatsby-source-filesystem failed at the option key being misspelled, but gatsby-plugin-google-analytics fails silently and makes it seem like everything is fine.

gatsby-source-filesystem

  • resolve changed to resolv
plugins: [
  'gatsby-plugin-react-helmet',
  {
    resolv: `gatsby-source-filesystem`,
    options: {
      name: `images`,
      path: `${__dirname}/src/images`,
    }
  }
]
  • options changed to option
plugins: [
  'gatsby-plugin-react-helmet',
  {
    resolv: `gatsby-source-filesystem`,
    option: {
      name: `images`,
      path: `${__dirname}/src/images`,
    }
  }
]
  • Error
UNHANDLED REJECTION The "path" argument must be of type string. Received type object
Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object

gatsby-plugin-google-analytics

This fails silently. To be thorough, it does indeed fail if resolve key is misspelled.

  • options changed to option
plugins: [
  'gatsby-plugin-react-helmet',
  {
    resolve: `gatsby-plugin-google-analytics`,
    option: {
      trackingId: "3747g9fd",
      head: true,
    }
  }
]
  • Error
No error. Fails silently, and plugin does not load.

OS Info

System:
  OS: Windows 10 10.0.18362
  CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Binaries:
  Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
  npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
Languages:
  Python: 2.7.5
Browsers:
  Edge: 44.18362.449.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment