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.

After reinstalling all npm modules without yarn.lock

See original GitHub issue

Description

I reinstalled all npm modules without yarn.lock and got this error. In the demo-repo I saved yarn.lock that breaks build. Also I added yarn.lock.nice with which build works fine.

gatsby build returns the following error:

 ERROR #85910  GRAPHQL

Multiple "root" queries found: "yQuery" and "BlogPostBySlug".
Only the first ("BlogPostBySlug") will be registered.

Instead of:

   1 | query BlogPostBySlug {
   2 |   allMarkdownRemark {
   3 |     #...
   4 |   }
   5 | }
   6 | 
   7 | query yQuery {
   8 |   site {
   9 |     #...
  10 |   }
  11 | }

Do:

  1 | query yQueryAndBlogPostBySlug {
  2 |   allMarkdownRemark {
  3 |     #...
  4 |   }
  5 |   site {
  6 |     #...
  7 |   }
  8 | }

This can happen when you use two page/static queries in one file. Please combine those into one query.
If you're defining multiple components (each with a static query) in one file, you'll need to move each component to its own file.

File: src/templates/blog-post.tsx

Steps to reproduce

I’ve prepared demo repo After clonning do the following steps: yarn install gatsby build

Expected result

build should complete

Actual result

build failed

Environment

System: OS: Linux 4.15 Ubuntu 16.04.6 LTS (Xenial Xerus) CPU: (8) x64 AMD FX™-8350 Eight-Core Processor Shell: 4.3.48 - /bin/bash Binaries: Node: 10.14.1 - /usr/local/bin/node Yarn: 1.17.3 - /usr/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Languages: Python: 2.7.12 - /usr/bin/python Browsers: Chrome: 76.0.3809.87 npmPackages: gatsby: ^2.3.16 => 2.18.17 gatsby-image: ^2.0.37 => 2.2.37 gatsby-plugin-feed: ^2.1.0 => 2.3.25 gatsby-plugin-google-analytics: ^2.0.18 => 2.1.31 gatsby-plugin-lodash: ^3.0.5 => 3.1.18 gatsby-plugin-mailchimp: ^5.1.0 => 5.1.2 gatsby-plugin-manifest: ^2.0.28 => 2.2.34 gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0 gatsby-plugin-netlify-cms: ^4.1.33 => 4.1.33 gatsby-plugin-offline: ^2.0.25 => 2.2.10 gatsby-plugin-prefetch-google-fonts: ^1.4.2 => 1.4.3 gatsby-plugin-react-helmet: ^3.0.12 => 3.1.18 gatsby-plugin-sharp: ^2.0.32 => 2.3.10 gatsby-plugin-styled-components: ^3.0.7 => 3.1.16 gatsby-plugin-typescript: ^2.0.12 => 2.1.23 gatsby-remark-copy-linked-files: ^2.0.11 => 2.1.33 gatsby-remark-images: ^2.0.6 => 2.0.6 gatsby-remark-katex: ^3.0.4 => 3.1.20 gatsby-remark-mermaid: ^1.0.0 => 1.2.0 gatsby-remark-prismjs: ^3.2.8 => 3.3.28 gatsby-remark-relative-images: ^0.2.3 => 0.2.3 gatsby-remark-responsive-iframe: ^2.1.1 => 2.2.30 gatsby-remark-smartypants: ^2.0.9 => 2.1.19 gatsby-source-filesystem: ^2.0.29 => 2.1.43 gatsby-source-instagram: ^0.5.0 => 0.5.1 gatsby-transformer-remark: ^2.3.8 => 2.6.45 gatsby-transformer-sharp: ^2.1.17 => 2.3.9 npmGlobalPackages: gatsby-cli: 2.7.53

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
micpossocommented, Apr 25, 2020

I’m getting the error in the default blog starter template: Multiple “root” queries found: “BlogPostBySlug” and “BlogPostBySlug” There is only one root query on my template file templates/blog-post.js. When it’s removed, the homepage loads, but none of the posts work. Is this an issue with the version of gatsbly CLI?

2reactions
vladarcommented, Dec 26, 2019

We reworked query extraction recently. The new extractor discovered this error when the old one (erroneously) skipped it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Have to reinstall node_modules every time I install a package
delete node modules and package-lock.json and Run yarn ... Try with these commands after delete node_modules folder. $ npm cache clean
Read more >
yarn install
Install all the dependencies listed within package.json in the local node_modules folder. The yarn.lock file is utilized as follows: ... If you want...
Read more >
npm-install - npm Docs
This command installs a package and any packages that it depends on. If the package has a package-lock, or an npm shrinkwrap file,...
Read more >
Yarn lock: how it works and what you risk without maintaining ...
Question: You installed project dependencies at some point. Time has passed, maybe a few of your project dependencies released a new version. ...
Read more >
Detect "node-modules" under "packages" folder, remove them ...
Description Some users are installing things under the folder of their package which creates a “node_modules” folder.
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