question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gatsby build fails when StaticQuery has closing tag

See original GitHub issue

Description

When I use <StaticQuery></StaticQuery> gatsby build fails. When I use <StaticQuery />, everything works.

Failure message:

Error: ./src/components/layout.js
  Module build failed (from ./node_modules/babel-loader/lib/index.js):
  TypeError: Cannot read property 'push' of undefined

This happens at the following location: https://github.com/gatsbyjs/gatsby/blob/f41eb2a58d8a8d5e84663bb6a9080aa6b3d530df/packages/babel-plugin-remove-graphql-queries/src/index.js#L139

The value of path2.parent is:

Node {
  type: 'JSXClosingElement',
  start: 1095,
  end: 1109,
  loc:
   SourceLocation {
     start: Position { line: 38, column: 8 },
     end: Position { line: 38, column: 22 } },
  name:
   Node {
     type: 'JSXIdentifier',
     start: 1097,
     end: 1108,
     loc: SourceLocation { start: [Position], end: [Position] },
     name: 'StaticQuery' } }

Environment

System: OS: Linux 4.13 Ubuntu 17.10 (Artful Aardvark) CPU: x64 AMD A10-6700 APU with Radeon™ HD Graphics Shell: 5.2 - /usr/bin/zsh Binaries: Node: 9.10.1 - /usr/local/bin/node Yarn: 1.6.0 - /usr/local/bin/yarn npm: 5.8.0 - /usr/local/bin/npm Browsers: Chrome: 65.0.3325.162 Firefox: 60.0.2 npmPackages: gatsby: next => 2.0.0-beta.9 gatsby-plugin-react-helmet: next => 3.0.0-beta.2 gatsby-plugin-sharp: next => 2.0.0-beta.2 gatsby-plugin-typography: next => 2.2.0-beta.2 gatsby-remark-component: ^1.1.3 => 1.1.3 gatsby-remark-copy-linked-files: next => 2.0.0-beta.2 gatsby-remark-emojis: ^0.2.3 => 0.2.3 gatsby-remark-generic-extensions: ^0.0.1 => 0.0.1 gatsby-remark-images: next => 2.0.1-beta.3 gatsby-remark-smartypants: ^1.4.12 => 1.4.12 gatsby-source-filesystem: next => 2.0.1-beta.3 gatsby-transformer-remark: next => 2.1.1-beta.2

File contents (if changed)

gatsby-config.js: N/A package.json: N/A gatsby-node.js: N/A gatsby-browser.js: N/A gatsby-ssr.js: N/A

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
joshdcuneocommented, Jul 8, 2018

No dramas. I did the same a couple of days ago I’m pretty sure. 😄

1reaction
joshdcuneocommented, Jul 8, 2018

I may be wrong @deadcoder0904 but I my understanding is that the StaticQuery component receives the data prop so you could remove the data in this line since it doesn’t do anything.

const Layout = ({ children, data }) => (

The other components (Helment etc) can only access ‘data’ when they are rendered within StaticQuery because ‘data’ is passed as a prop to StaticQuery not Layout.

Sorry if that is a bad explanation, hopefully it still helps to clarify!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gatsby - GraphQL - StaticQuery tag - site fails to compile due ...
I'm trying to do a simple GraphQL query of my gatsby site's wordpress db and render the results. However, the site fails to...
Read more >
Part 4: Query for Data with GraphQL - Gatsby
Be sure to use the graphql tag so Gatsby knows that the string you're passing in is a GraphQL query. Store the return...
Read more >
How To Use Static Files in Gatsby | DigitalOcean
The StaticFilesDemo function is a React component that returns JSX, which becomes the page content. You use export default StaticFilesDemo as ...
Read more >
Troubleshooting Common Errors | GatsbyJS 中文网
This guide is meant as a reference for common errors that have tripped up other Gatsby users. Problems with the cache. Running a...
Read more >
[Gatsby] Solutions to "The result of this StaticQuery could not ...
Hi there! I'm Arisa, a DevRel from this June living in Germany (A big announcement is coming this... Tagged...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found