Gatsby开发作品,但构建失败并显示graphQL警告

时间:2020-03-08 21:11:17

标签: gatsby

我是Gatsby的新手,所以我可能做错了事。

我开始使用经过修改的gatsby起动器。由于一切进展顺利,我决定尝试进行构建...但失败了。

该错误表明它无法读取属性,因为它为null。更深入地研究事物,我认为错误的真正原因是以下警告:

    warn The GraphQL query in the non-page component
Exported queries are only executed for Page components. It's possible you're
trying to create pages in your gatsby-node.js and that's failing for some
reason.

If the failing component(s) is a regular component and not intended to be a page
component, you generally want to use a <StaticQuery> (https://gatsbyjs.org/docs/static-query)
instead of exporting a page query.

If you're more experienced with GraphQL, you can also export GraphQL
fragments from components and compose the fragments in the Page component
query and pass data down into the child component — http://graphql.org/learn/queries/#fragments

我确保我将StaticQuery用于非页面组件。另外,在我进行gatsby开发而不是build时,我没有得到警告或错误。

我不确定现在该怎么办。 任何建议都会很棒!

0 个答案:

没有答案