Gatsby: [Help] Gatsby not building static html correctly

Created on 13 Jul 2017  ยท  30Comments  ยท  Source: gatsbyjs/gatsby

Hey all. My project currently works perfectly running in gatsby develop but whenever I go to run gatsby build it will build the css, and bundle.js fine, but it runs into an error on building the static html.

I'm currently building with Gatsby, gatsby-plugin-styled-components and using the rebass component library. My dependencies are as follows:

"dependencies": {
    "gatsby": "latest",
    "gatsby-link": "latest",
    "gatsby-plugin-react-helmet": "latest",
    "gatsby-plugin-styled-components": "latest",
    "grid-styled": "^2.0.0-8",
    "react-typography": "^0.15.0",
    "rebass": "next",
    "typography": "^0.15.8",
    "typography-breakpoint-constants": "^0.14.0",
    "typography-plugin-code": "^0.15.9"
  },
  "devDependencies": {
    "datocms-client": "^0.3.25",
    "gh-pages": "^0.12.0"
  }

My terminal print out is below:

```success open and validate gatsby-config.js โ€” 0.008 s
success copy gatsby files โ€” 0.035 s
success source and transform nodes โ€” 0.030 s
success building schema โ€” 0.192 s
success createPages โ€” 0.003 s
success createPagesStatefully โ€” 0.063 s
success extract queries from components โ€” 0.017 s
success run graphql queries โ€” 0.017 s
success write out page data โ€” 0.006 s
success update schema โ€” 0.130 s

bootstrap finished, time since started: 2.287 s

Generating CSS
Compiling production bundle.js
Generating static HTML for pages

Error: Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35)
```

If anyone has any idea on what is causing this error the help would be much appreciated!

Most helpful comment

nvm. the issue was i had an unused file in the pages folder.

All 30 comments

I've run into this myself on Netlify using node 8+ and npm 5. Using npm < 5 or yarn install instead should solve it.

Or you can npm install invariant into your project for the time being.

EDIT: Oops, it actually looks like Invariant is running there.

People are saying NPM 5.1+ seems to be working. So try that or yarn.

Updated NPM to 5.2 and tried Yarn and had no luck with either. Still getting the following:
@michaeljdeeb @KyleAMathews

``` yarn build v0.23.4
$ gatsby build
success open and validate gatsby-config.js โ€” 0.008 s
success copy gatsby files โ€” 0.172 s
success source and transform nodes โ€” 0.249 s
success building schema โ€” 0.451 s
success createPages โ€” 0.007 s
success createPagesStatefully โ€” 0.374 s
success extract queries from components โ€” 0.016 s
success run graphql queries โ€” 0.020 s
success write out page data โ€” 0.004 s
success update schema โ€” 0.110 s

bootstrap finished, time since started: 5.379 s

Generating CSS
Compiling production bundle.js
Generating static HTML for pages

Error: Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35),Invariant Violation: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60Route%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at reactProdInvariant (render-page.js:5458:16)
at ReactCompositeComponentWrapper.instantiateReactComponent [as _instantiateReactComponent] (render-page.js:14748:219)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15173:23)
at ReactCompositeComponentWrapper.mountComponent (render-page.js:15064:22)
at Object.mountComponent (render-page.js:7976:36)
at ReactDOMComponent.mountChildren (render-page.js:14205:45)
at ReactDOMComponent._createContentMarkup (render-page.js:11215:33)
at ReactDOMComponent.mountComponent (render-page.js:11082:30)
at Object.mountComponent (render-page.js:7976:36)
at ReactCompositeComponentWrapper.performInitialMount (render-page.js:15177:35)

Generating static HTML for pages failed
```

Here is building fine but I can see the error

Uncaught Error: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]=%20Check%20the%20render%20method%20of%20%60t%60. for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

Nothing is showing when developing it, almost impossible to debug ๐Ÿ˜”

@KyleAMathews this is actually the error I am getting on #1547. It only shows up in build in the console. I am building from a yarn based master/contributing branch and seeing this. I have basically stripped everything out of the site at this point, and I am still seeing the error. This one is a bugger. It feels like we have something breaking in the core as even the router is borked. It only loads the "pages" on a hard reload in chrome.

@jbolda Since none of the other example sites afaik have this bug it seems unlikely it's a core bug. Have you followed the link to the React docs site to see what the bug is? You can also build the site w/ uglify disabled to see the full error.

Yea, it says something expects a string and gets an object instead. Considering the stripped down state of my code at this point, I figured the error was deeper. I'll try out disabling uglify.

Possible TODO: add a cli switch to turn off uglify for debugging.

I'm getting the same Minified React error #130 here, it's only during build...

The full text of the error you just encountered is:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of Route

Node v7.5.0
Npm 5.3.0

ps: yarn didn't work either

So I had a placeholder graphql statement in my layout/index.js. It was there, not commented out, for when that support was added. Turns out that that is what was throwing the minification error. I commented out that whole block and no more error!

@KyleAMathews I found my issue as well. In layouts/index.js I was exporting shared components apart from export default class Template moving things to layouts/shared.js solved my issue ๐Ÿ‘Œ

Note: In my case the build was successful but I'd see the same minified error message in the page.

Had the same error.
The problem was with a page using export instead of export default

Mine was a silly error, I duplicated a page for starting a new one and forgot to change the class name...

I have the same error but I couldn't figure out the issue. It was fine when I used gatsby develop until I tried gatsby build. I also have the same error on netlify. Anyone has an idea that isn't one from above?

```success delete html files from previous builds โ€” 0.023 s
success open and validate gatsby-config.js โ€” 0.005 s
success copy gatsby files โ€” 0.019 s
success source and transform nodes โ€” 0.072 s
success building schema โ€” 0.201 s
success createLayouts โ€” 0.009 s
success createPages โ€” 0.001 s
success createPagesStatefully โ€” 0.037 s
success extract queries from components โ€” 0.143 s
success run graphql queries โ€” 0.005 s
success write out page data โ€” 0.002 s
success update schema โ€” 0.136 s

info bootstrap finished - 3.07 s

success Building CSS โ€” 6.784 s
success Building production JavaScript bundles โ€” 18.185 s

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://goo.gl/yL9lND

29 | message += ' for the full message or use the non-minified dev environment' + ' for full errors and additional helpful warnings.';
30 |

31 | var error = new Error(message);
| ^
32 | error.name = 'Invariant Violation';
33 | error.framesToPop = 1; // we don't care about reactProdInvariant's own frame
34 |

WebpackError: Minified React error #130; visit http://facebook.github.io/react/docs/error-decoder.html?invariant=130&args[]=object&args[]= for the full m essage or use the non-minified dev environment for full errors and additional helpful warnings.

  • reactProdInvariant.js:31 reactProdInvariant
    ~/react-dom/lib/reactProdInvariant.js:31:1

  • instantiateReactComponent.js:74 instantiateReactComponent
    ~/react-dom/lib/instantiateReactComponent.js:74:1

  • ReactChildReconciler.js:44 instantiateChild
    ~/react-dom/lib/ReactChildReconciler.js:44:1

  • traverseAllChildren.js:77 traverseAllChildrenImpl
    ~/react-dom/lib/traverseAllChildren.js:77:1

  • traverseAllChildren.js:172 traverseAllChildren
    ~/react-dom/lib/traverseAllChildren.js:172:1

  • ReactChildReconciler.js:74 Object.instantiateChildren
    ~/react-dom/lib/ReactChildReconciler.js:74:1

  • ReactMultiChild.js:191 ReactDOMComponent._reconcilerInstantiateChildren
    ~/react-dom/lib/ReactMultiChild.js:191:1

  • ReactMultiChild.js:224 ReactDOMComponent.mountChildren
    ~/react-dom/lib/ReactMultiChild.js:224:1

  • ReactDOMComponent.js:659 ReactDOMComponent._createContentMarkup
    ~/react-dom/lib/ReactDOMComponent.js:659:1

  • ReactDOMComponent.js:526 ReactDOMComponent.mountComponent
    ~/react-dom/lib/ReactDOMComponent.js:526:1
    ```

nvm. the issue was i had an unused file in the pages folder.

@xinranwang thanks - you gave me a hint that helped me solve the issue for myself. I had a folder called src/pages/articles, and for my articles I wanted different eslint rules so I created src/pages/articles/.eslintrc.js. Removing .eslintrc.js made the error go away.

Maybe the page creator should ignore dot-files?

@ahfarmer hmmm that'd make sense. We already ignore file names starting with _. Would take a PR adding this!

I had this issue as well. It was working with gatsby develop, but the error showed up on gatsby build, although the build seemed to work correctly.

To fix it, I removed all files from the pages directory that were not intended to become pages. I had a content.js file I was using to import content variables, and it seems like that confused Mr. Gatsby. :)

A simple npm update ended up fixing my version of this error.

This was the error:

$ npm run build

> [email protected] build /Users/XYZ/Workspace/ABC/project-name
> gatsby build

success delete html files from previous builds โ€” 0.007 s
success open and validate gatsby-config.js โ€” 0.004 s
success copy gatsby files โ€” 0.022 s
success onPreBootstrap โ€” 0.005 s
success source and transform nodes โ€” 0.044 s
success building schema โ€” 0.400 s
success createLayouts โ€” 0.007 s
success createPages โ€” 0.021 s
success createPagesStatefully โ€” 0.018 s
success onPreExtractQueries โ€” 0.001 s
success update schema โ€” 0.117 s
GraphQL Error There was an error while compiling your site's GraphQL queries.


success extract queries from components โ€” 0.080 s
success run graphql queries โ€” 0.004 s
success write out page data โ€” 0.002 s
success write out redirect data โ€” 0.000 s
success onPostBootstrap โ€” 0.001 s

info bootstrap finished - 2.111 s

success Building CSS โ€” 7.289 s
success Building production JavaScript bundles โ€” 11.261 s

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://goo.gl/yL9lND

  45 |     const expanded = !mobile;
  46 |     const postOverlapClass = mobile ? "post-overlap-mobile" : "post-overlap";
> 47 |     const postNode = this.props.data.markdownRemark;
     |                                      ^
  48 |     const post = postNode.frontmatter;
  49 |     if (!post.id) {
  50 |       post.id = slug;


  WebpackError: Cannot read property 'markdownRemark' of undefined

  - post.jsx:47 PostTemplate.render
    src/templates/post.jsx:47:38

  - ReactCompositeComponent.js:796 ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext
    ~/react-dom/lib/ReactCompositeComponent.js:796:1

  - ReactCompositeComponent.js:819 ReactCompositeComponentWrapper._renderValidatedComponent
    ~/react-dom/lib/ReactCompositeComponent.js:819:1

  - ReactCompositeComponent.js:359 ReactCompositeComponentWrapper.performInitialMount
    ~/react-dom/lib/ReactCompositeComponent.js:359:1

  - ReactCompositeComponent.js:255 ReactCompositeComponentWrapper.mountComponent
    ~/react-dom/lib/ReactCompositeComponent.js:255:1

  - ReactReconciler.js:43 Object.mountComponent
    ~/react-dom/lib/ReactReconciler.js:43:1

  - ReactMultiChild.js:234 ReactDOMComponent.mountChildren
    ~/react-dom/lib/ReactMultiChild.js:234:1

  - ReactDOMComponent.js:657 ReactDOMComponent._createContentMarkup
    ~/react-dom/lib/ReactDOMComponent.js:657:1

  - ReactDOMComponent.js:524 ReactDOMComponent.mountComponent
    ~/react-dom/lib/ReactDOMComponent.js:524:1

  - ReactReconciler.js:43 Object.mountComponent
    ~/react-dom/lib/ReactReconciler.js:43:1


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `gatsby build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I had the same issue.

In my case, I was using typescript's apollo-codegen to generate type definitions from graphql queries in src/pages/index.tsx, but those type definitions generated in src/pages/__generated__ directory, which caused the above error. Simply cping those files out to some other directory outside pages fixed it.

I had this issue too, and it was really difficult to debug. I had to use a divide and conquer approach to finally figure out the file with issues.

Some debugging options here would be awesome, not sure how easy/hard that is.

I'm having same issue. All works fine under gatsby build. gatsby build runs with no error. I then gatsby serve the site locally, and some pages fail to load with the Minified React error #130;

Doesn't seem to be any of the issues above. Quite frustrating situation, a bit of a black box. I tried --no-uglify, which fails on git bash for windows, then --disable-uglify, which does run the build but I still get the Minified React error #130 (I'm expecting the full error given --disable-uglify, right?)

I'm pretty sure there is a bug in my site somewhere but it's really difficult to track down given level of error reporting and available tooling.

$ gatsby info

System:
OS: Windows 7
CPU: x64 Intel(R) Xeon(R) CPU E3-1225 V2 @ 3.20GHz
Binaries:
npm: 6.1.0 - C:\Program Files\nodejsnpm.CMD
npmPackages:
gatsby: ^2.0.0-beta.17 => 2.0.0-beta.17
gatsby-plugin-sass: ^2.0.0-beta.3 => 2.0.0-beta.3
gatsby-plugin-typescript: next => 2.0.0-beta.5

OK as per the above I painstakingly got to the proximate cause of my issue. I dont' feel it makes sense, or that there is a _good_ reason for it, but the order of imports seem to matter. See the import DefaultLayout line below. If it is in Position 1 the built site works fine. If in Position 2 built site gives react minified #130. Seems like order of imports matters? Just to re-iterate, in either position, all works fine in gastby develop. And in either position gatsby build completes without error. It's just that in Position 2 I get react minified #130 when gatsby serving the page AND when going direct to the page by entering its address into the browser. Navigating via internal site menus works fine. In position 1 all works fine.

import * as React from "react"

import DefaultLayout from "../layouts" //position 1: when this is here it built site works fine

import VisionsExplorer from "../components/VisionsExplorer/VisionsExplorer"
import IssueVisualizer from "../components/IssueVisualizer/IssueVisualizer";

import withAuthorization from "../session/withAuthorization"

import DefaultLayout from "../layouts" //position 2 when this is here built site fails with Minified React error #130**

class ExploreVisionsPage extends React.Component {
  constructor(props) {
    super(props)
  }
  render() {
    return (
      < DefaultLayout location={this.props.location} siteName={"TODO site name"} >
        <div className="container">
          <VisionsExplorer />
        </div>
      </DefaultLayout >
    )
  }
}

const authCondition = (authUser: User) => !!authUser
export default withAuthorization(authCondition)(ExploreVisionsPage)

Hi Everyone,

I had the exact same issue and received the Minified React error on build.

After reading many of the above comments, it appears you shouldn't have unwanted files within the pages directory. I include my CSS-in-JS files in a seperate JS file and label it very similar to my page file. Moving my styling files to another folder solved the issue.

In my case, Netlify was using v0.18.1 of Yarn. The build passed after setting environment variable YARN_VERSION to 1.9.2.

I wanted to post my solution to help others.

I had added a file within the /src/pages folder which was not a page to be built. In my case it was a styled components file containing styles for my index.js page.

Thanks to the comments above, my brain cells started working together and spotted this when going through my commits.

I had an issue like @andyshora and @nimaiwalsh had, in that my styled components file was in the /pages directory. I moved that, and all my other styled component files, to a /styling directory in /src and yarn build completed just fine.

I got the error when I made a new page (in /pages) and left if blank. As soon as I added some javascript to my new page file the site built without any errors.

I'm still getting the same error even though I removed all files (just one index.jsx) in /pages...

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://gatsby.app/debug-html

   8 |  else
   9 |      root["lib"] = factory(root["@reach/router"], root["core-js/library/fn/json/stringify"], root["core-js/library/fn/object/assign"], root["core-js/library/fn/object/create"], root["core-js/library/fn/object/define-property"], root["core-js/library/fn/object/get-prototype-of"], root["core-js/library/fn/object/keys"], root["core-js/library/fn/object/set-prototype-of"], root["core-js/library/fn/symbol"], root["core-js/library/fn/symbol/iterator"], root["core-js/modules/es6.array.iterator"], root["core-js/modules/es6.array.sort"], root["core-js/modules/es6.function.name"], root["core-js/modules/es6.map"], root["core-js/modules/es6.object.assign"], root["core-js/modules/es6.regexp.constructor"], root["core-js/modules/es6.regexp.replace"], root["core-js/modules/es6.regexp.split"], root["core-js/modules/es6.regexp.to-string"], root["core-js/modules/es6.string.ends-with"], root["core-js/modules/es6.string.iterator"], root["core-js/modules/web.dom.iterable"], root["debug"], root["fs"], root["lodash"], root["lodash/cloneDeep"], root["lodash/isEqual"], root["lodash/kebabCase"], root["minimatch"], root["path"], root["pify"], root["react"], root["react-dom/server"], root["react-helmet"]);
> 10 | })(this, function(__WEBPACK_EXTERNAL_MODULE__reach_router__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_json_stringify__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_assign__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_create__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_define_property__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_get_prototype_of__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_keys__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_object_set_prototype_of__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_symbol__, __WEBPACK_EXTERNAL_MODULE_core_js_library_fn_symbol_iterator__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_array_iterator__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_array_sort__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_function_name__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_map__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_object_assign__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_constructor__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_replace__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_split__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_to_string__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_string_ends_with__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_string_iterator__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_web_dom_iterable__, __WEBPACK_EXTERNAL_MODULE_debug__, __WEBPACK_EXTERNAL_MODULE_fs__, __WEBPACK_EXTERNAL_MODULE_lodash__, __WEBPACK_EXTERNAL_MODULE_lodash_cloneDeep__, __WEBPACK_EXTERNAL_MODULE_lodash_isEqual__, __WEBPACK_EXTERNAL_MODULE_lodash_kebabCase__, __WEBPACK_EXTERNAL_MODULE_minimatch__, __WEBPACK_EXTERNAL_MODULE_path__, __WEBPACK_EXTERNAL_MODULE_pify__, __WEBPACK_EXTERNAL_MODULE_react__, __WEBPACK_EXTERNAL_MODULE_react_dom_server__, __WEBPACK_EXTERNAL_MODULE_react_helmet__) {
     |  ^
  11 | return


  WebpackError: Invariant Violation: Minified React error #130; visit https://reactjs.org/docs/erro  r-decoder.html?invariant=130&args[]=undefined&args[]= for the full message or use the non-minifie  d dev environment for full errors and additional helpful warnings.

  - universalModuleDefinition:10 ba
    lib/webpack/universalModuleDefinition:10:2




  - bootstrap:40 renderToString
    lib/webpack/bootstrap:40:1

  - static-entry.js:190 Module.default
    lib/.cache/static-entry.js:190:18

  - bootstrap:24 Promise
    lib/webpack/bootstrap:24:1



  - bootstrap:68 new Promise
    lib/webpack/bootstrap:68:1


  - bootstrap:5 tryCatcher
    lib/webpack/bootstrap:5:1

  - bootstrap:50 MappingPromiseArray._promiseFulfilled
    lib/webpack/bootstrap:50:1

  - api-runner-ssr.js:6 MappingPromiseArray.PromiseArray._iterate
    lib/.cache/api-runner-ssr.js:6:16

  - bootstrap:67 MappingPromiseArray.init
    lib/webpack/bootstrap:67:1

  - bootstrap:19 MappingPromiseArray._asyncInit
    lib/webpack/bootstrap:19:1

I wonder if something new was added that is causing this now?

I don't have any non-pages in my pages directory but I am getting this error. I have absolutely no clue what is causing it. It runs fine with 'gatsby develop'. This happens during gatsby build. I've chased down all of the clues I can think of based on the the great comments on this issue.

success Building production JavaScript and CSS bundles โ€” 102.249 s

error Building static HTML for pages failed

See our docs page on debugging HTML builds for help https://gatsby.app/debug-html

   8 |  else
   9 |      root["lib"] = factory(root["@reach/router"], root["core-js/modules/es6.array.iterator"], root["core-js/modules/es6.array.sort"], root["core-js/modules/es6.function.name"], root["core-js/modules/es6.map"], root["core-js/modules/es6.object.assign"], root["core-js/modules/es6.regexp.constructor"], root["core-js/modules/es6.regexp.replace"], root["core-js/modules/es6.regexp.search"], root["core-js/modules/es6.regexp.split"], root["core-js/modules/es6.regexp.to-string"], root["core-js/modules/es6.string.ends-with"], root["core-js/modules/es6.string.iterator"], root["core-js/modules/web.dom.iterable"], root["fs"], root["lodash"], root["lodash/cloneDeep"], root["path"], root["react"], root["react-dom/server"]);
> 10 | })(this, function(__WEBPACK_EXTERNAL_MODULE__reach_router__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_array_iterator__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_array_sort__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_function_name__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_map__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_object_assign__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_constructor__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_replace__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_search__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_split__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_regexp_to_string__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_string_ends_with__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_es6_string_iterator__, __WEBPACK_EXTERNAL_MODULE_core_js_modules_web_dom_iterable__, __WEBPACK_EXTERNAL_MODULE_fs__, __WEBPACK_EXTERNAL_MODULE_lodash__, __WEBPACK_EXTERNAL_MODULE_lodash_cloneDeep__, __WEBPACK_EXTERNAL_MODULE_path__, __WEBPACK_EXTERNAL_MODULE_react__, __WEBPACK_EXTERNAL_MODULE_react_dom_server__) {
     |  ^
  11 | return 


  WebpackError: Invariant Violation: Minified React error #130; visit https://reactjs.org/docs/error-decoder.h  tml?invariant=130&args[]=object&args[]= for the full message or use the non-minified dev environment for ful  l errors and additional helpful warnings.

  - universalModuleDefinition:10 ba
    lib/webpack/universalModuleDefinition:10:2



  - bootstrap:24 a.read
    lib/webpack/bootstrap:24:1

  - bootstrap:36 renderToString
    lib/webpack/bootstrap:36:1

  - static-entry.js:190 Module.default
    lib/.cache/static-entry.js:190:18

  - bootstrap:24 Promise
    lib/webpack/bootstrap:24:1


  - static-entry.js:4 Promise._resolveFromExecutor
    lib/.cache/static-entry.js:4:25

  - bootstrap:68 new Promise
    lib/webpack/bootstrap:68:1


  - bootstrap:5 tryCatcher
    lib/webpack/bootstrap:5:1

  - bootstrap:50 MappingPromiseArray._promiseFulfilled
    lib/webpack/bootstrap:50:1

  - api-runner-ssr.js:10 MappingPromiseArray.PromiseArray._iterate
    lib/.cache/api-runner-ssr.js:10:1

  - bootstrap:67 MappingPromiseArray.init
    lib/webpack/bootstrap:67:1

  - bootstrap:19 MappingPromiseArray._asyncInit
    lib/webpack/bootstrap:19:1

Can also occur if trying to import something that doesn't exist. For some reason it doesn't break in development but when you build it breaks, wish the error could be a bit clearer...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  ยท  3Comments

kalinchernev picture kalinchernev  ยท  3Comments

andykais picture andykais  ยท  3Comments

signalwerk picture signalwerk  ยท  3Comments

brandonmp picture brandonmp  ยท  3Comments