WebpackError: Cannot read property 'node' of undefined
antonioOrtiz opened this issue · comments
Anyone run into this when trying to run a build?
error Building static HTML for pages failed
See our docs page on debugging HTML builds for help https://goo.gl/yL9lND
58 | ? this.props.data.allAuthorsJson.edges
59 | : [];
> 60 | const getAuthor = () => authorsEdges[0].node;
| ^
61 |
62 | return (
63 | <Drawer className="author-template" isOpen={this.state.menuOpen}>
WebpackError: Cannot read property 'node' of undefined
- author.jsx:60 getAuthor
src/templates/author.jsx:60:45
- author.jsx:78 AuthorTemplate.render
src/templates/author.jsx:78:34
- ReactCompositeComponent.js:796 ReactCompositeComponentWrapper._renderValidatedComponentWithoutO wnerOrContext
~/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
Unfortunately, that error message is miss-leading, this is the actual error.
> 60 | const getAuthor = () => authorsEdges[0].node;
Check the blogAuthorDir
value in your data/SiteConfig.js file. Within that folder, there MUST be an 'authors' folder, which MUST contains at least one author JSON file.
Author filename example for 'casper' user:
casper.json
Expected formatting for an author JSON file:
{
"id": "casper",
"name": "Casper User",
"image": "https://api.adorable.io/avatars/150/test.png",
"url": "http://gatsbyjs.org/",
"location": "North Pole, Earth",
"bio": "Yeah, I like animals better than people sometimes... Especially dogs. Dogs are the best. Every time you come home, they act like they haven't seen you in a year. And the good thing about dogs... is they got different dogs for different people.",
"socialUrls": [
"https://github.com/gatsbyjs",
"https://twitter.com/gatsbyjs",
"mailto:gatsbyjs@example.com"
]
}
@antonioOrtiz Feel free to re-open this issue if you are still running into trouble.
Hi Everyone, I got the following error message while running the
gatsby build
command for the first time.
However,
gatsby develop
command works fine. Could you please help me on this 😊.
Hi @haysclark after adding nodes in pageContex property in tag.jsx issue is fixed now. Like this
pageContext: { nodes, tag, page, pages, total, limit, prev, next }
But still there is the cannot find module '!raw-loader'
warning is still there.