Gatsby build error on Netlify: error Multiple “root” queries found in file

时光总嘲笑我的痴心妄想 提交于 2020-03-03 14:02:00

问题


I cannot make a build on Netlify but I did it successfully in my terminal on macOS.

What does "root queries" mean?, does anyone got same issue ? Here's the log from netlify:

11:10:25 AM: success createPagesStatefully - 0.217s
11:10:25 AM: success onPreExtractQueries - 0.000s
11:10:25 AM: success update schema - 0.065s
11:10:25 AM: error Multiple "root" queries found in file: "headerTitleQuery" and "headerTitleQuery".
11:10:25 AM: Only the first ("headerTitleQuery") will be registered.
11:10:25 AM: Instead of:
11:10:25 AM: 1 | query headerTitleQuery {
11:10:25 AM: 2 |   bar {
11:10:25 AM: 3 |     #...
11:10:25 AM: 4 |   }
11:10:25 AM: 5 | }
11:10:25 AM: 6 |
11:10:25 AM: 7 | query headerTitleQuery {
11:10:25 AM: 8 |   foo {
11:10:25 AM: 9 |     #...
11:10:25 AM: 10 |   }
11:10:25 AM: 11 | }
11:10:25 AM: Do:
11:10:25 AM: 1 | query headerTitleQueryAndHeaderTitleQuery {
11:10:25 AM: 2 |   bar {
11:10:25 AM: 3 |     #...
11:10:25 AM: 4 |   }
11:10:25 AM: 5 |   foo {
11:10:25 AM: 6 |     #...
11:10:25 AM: 7 |   }
11:10:25 AM: 8 | }
11:10:25 AM: failed extract queries from components - 0.496s
11:10:25 AM: Skipping functions preparation step: no functions directory set
11:10:25 AM: Caching artifacts
11:10:26 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
11:10:25 AM: Started saving node modules
11:10:25 AM: Finished saving node modules
11:10:25 AM: Started saving yarn cache
11:10:25 AM: Finished saving yarn cache
11:10:25 AM: Started saving pip cache
11:10:26 AM: Shutting down logging, 12 messages pending
11:10:25 AM: Finished saving pip cache

回答1:


Ok, I get it solved.

More than a little research I had to remember what thing I did before that happened, it turns out I had got a case-sensitive issue so I needed to make some changes in such a way that result in two files with the same name under the same folder.

That means I indeed had two identical components (Header.js and header.js) trying to execute the same query headerTitleQuery in middle of the build process, so I deleted header.js and the nightmare is over.

In short, to get it solved just make sure you have only unique-name component files and don't ignore the case-sensitive filenames when you work on both linux and macOS.

Why does it work on my macOS terminal ?

Because my local workspace on macOS is ignoring the case-sensitive filenames, Netlify (which operates over linux instances) just doesn't do that.



来源:https://stackoverflow.com/questions/60399765/gatsby-build-error-on-netlify-error-multiple-root-queries-found-in-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!