gatsby: Develop/Build fails on `extracting-queries` with latest Gatsby (glob 7.2.2)

Preliminary Checks

Description

When attempting to use the YARN package manager, the gatsby develop server fails on the extract queries from components step with the error message:

Missing onError handler for invocation ‘extracting-queries’, error was ‘TypeError: Cannot read properties of undefined (reading ‘charAt’)’. Stacktrace was 'TypeError: Cannot read properties of undefined
(reading ‘charAt’)

Reproduction Link

https://www.gatsbyjs.com/docs/tutorial/part-1/

Steps to Reproduce

  1. Install gatesby
  2. run gatesby new
  3. select ‘yarn’ as package manager (or ensure you have set this previously)
  4. run gatesby develop
  5. observe error

Expected Result

Several things:

  1. gatesby development server should start
  2. gatesby should provide a more useful error message

Actual Result

Missing onError handler for invocation 'extracting-queries', error was 'TypeError: Cannot read properties of undefined (reading 'charAt')'. Stacktrace was 'TypeError: Cannot read properties of undefined        
(reading 'charAt')
    at GlobSync._processReaddir (C:\Users\...\gatsby test\gatsby_yarn\node_modules\glob\sync.js:148:35)
    at GlobSync._process (C:\Users\...\gatsby test\gatsby_yarn\node_modules\glob\sync.js:132:10)
    at new GlobSync (C:\Users\...\gatsby test\gatsby_yarn\node_modules\glob\sync.js:45:10)
    at Function.sync (C:\Users\...\gatsby test\gatsby_yarn\node_modules\glob\sync.js:23:10)
    at reduce (C:\Users\...\gatsby test\gatsby_yarn\node_modules\gatsby\src\query\query-compiler.js:128:15)
    at Array.reduce (<anonymous>)
    at parseQueries (C:\Users\...\gatsby test\gatsby_yarn\node_modules\gatsby\src\query\query-compiler.js:126:5)
    at compile (C:\Users\...\gatsby test\gatsby_yarn\node_modules\gatsby\src\query\query-compiler.js:65:25)
    at updateStateAndRunQueries (C:\Users\...\gatsby test\gatsby_yarn\node_modules\gatsby\src\query\query-watcher.ts:223:40)
    at extractQueries (C:\Users\...\gatsby test\gatsby_yarn\node_modules\gatsby\src\services\extract-queries.ts:18:3)'

⠙ extract queries from components

Environment

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5700G with Radeon Graphics         
  Binaries:
    Node: 18.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.15 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.8.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.10.4
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (101.0.1210.39)
  npmPackages:
    gatsby: ^4.14.0 => 4.14.0 
    gatsby-plugin-emotion: ^7.14.0 => 7.14.0 
  npmGlobalPackages:
    gatsby-cli: 4.14.0

Config Flags

No

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 11
  • Comments: 19 (4 by maintainers)

Most upvoted comments

Published patch of gatsby (4.14.1) that bumps minimal requirerment for glob to not allow glob@7.2.2 - https://www.runpkg.com/?gatsby@4.14.1/package.json#101

Just for reference - this issue was reported in upstream https://github.com/isaacs/node-glob/issues/471 and https://github.com/isaacs/node-glob/issues/474 and both are resolved with glob@7.2.3 release

Same issue after updating gatsby from v4.13.1 to 4.14.0. I am using “npm” and also Windows OS. Version of “glob” library is 7.2.2 gatsby clean didn’t` fix it.

Late Edit: Managed to get it fixed by putting this in my package.json

  "overrides": {
    "glob": "7.2.0"
  },

Essentially using an older version of this transitive dependency.

Same issue, is there any solution for this error? I have fixed this issue by downgrade of gatsby. (even it can’t be called good way), I hope someone deploy correct and smart way.

here is what I did. “gatsby”: “^3.9.1”, “gatsby-link”: “^3.9.0”, “gatsby-plugin-google-gtag”: “^3.9.0”, “gatsby-plugin-image”: “^1.14.1”, “gatsby-plugin-layout”: “^2.9.0”, “gatsby-plugin-manifest”: “^3.9.0”, “gatsby-plugin-module-resolver”: “^1.0.3”, “gatsby-plugin-react-helmet”: “^4.9.0”, “gatsby-plugin-react-svg”: “^3.0.1”, “gatsby-plugin-sass”: “^4.9.0”, “gatsby-plugin-sharp”: “^3.14.1”, “gatsby-react-router-scroll”: “^4.9.0”, “gatsby-source-filesystem”: “^3.14.0”, “gatsby-transformer-sharp”: “^3.14.0”, “gatsby-plugin-postcss”: “^4.9.0”,

(npm install after clear package.lock and node_module,)

@Alexyoe

Same issue. Glob fix doesn’t seem to help. "gatsby": "^4.12.1"

Did you try to remove node_modules package-lock.json and reinstall packages with overrides section ? Probably package-lock.json has gatsby 4.14.0 and glob 7.2.2 because record "^4.12.1" means that package manager can install latest minor version Also you can find installed version of package in package-lock.json or npm view gatsby version

@draghia-andrei Thanks. You right. gatsby 4.13.0 has devDependencies “glob”: “^7.1.7”.
gatsby 4.14.0 has devDependencies “glob”: “^7.2.0” , so ^ installed glob 7.2.2 which published a day ago

I guess to overrides glob only for gatsby "overrides": { "gatsby": { "glob": "7.2.0" } }