gatsby: TypeError: getNodesByType is not a function

Description

Hi there, I’ve been following the tutorials on gatsbyjs.org, and on part 6 I run into this issue where my app will crash whenever I try to query something with graphql.

Steps to reproduce

Here’s the github link to the project ➡️ https://github.com/ChariseWalraven/gatsby-graphql-crash

Expected result

GraphiQL and GraphQL should respond with the data from the markdown file.

Actual result

Crashed with the following error: screenshot from 2018-10-29 22-00-03 screenshot from 2018-10-29 22-00-11

Environment

  System:
    OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: x64 AMD A10-9620P RADEON R5, 10 COMPUTE CORES 4C+6G
    Shell: 5.4.2 - /usr/bin/zsh
  Binaries:
    Node: 11.0.0 - /usr/local/bin/node
    Yarn: 1.10.1 - /usr/bin/yarn
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 70.0.3538.67
    Firefox: 62.0.3
  npmPackages:
    gatsby: ^2.0.0 => 2.0.32 
    gatsby-plugin-emotion: ^2.0.6 => 2.0.6 
    gatsby-plugin-typography: ^2.2.1 => 2.2.1 
    gatsby-source-filesystem: ^2.0.6 => 2.0.6 
    gatsby-transformer-remark: ^2.1.11 => 2.1.11 
  npmGlobalPackages:
    gatsby-cli: 2.4.4

error Couldn't find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel


  Error: Couldn't find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel
  
  - envinfo.js:1 i
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:105475
  
  - envinfo.js:1 Object.copySync
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:106001
  
  - envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123499
  
  - envinfo.js:1 
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124274
  
  - envinfo.js:1 Promise.all.then.e
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124289
  
  - util.js:16 tryCatcher
    [lib]/[gatsby-cli]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18
  
  - promise.js:638 Promise._fulfill
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:638:18
  
  - promise_array.js:126 PromiseArray._resolve
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:126:19
  
  - promise_array.js:144 PromiseArray._promiseFulfilled
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:144:14
  
  - promise.js:574 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:574:26
  
  - promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18
  

error UNHANDLED REJECTION


  Error: Couldn't find the required `xsel` binary. On Debian/Ubuntu you can install it with: sudo apt install xsel
  
  - envinfo.js:1 i
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:105475
  
  - envinfo.js:1 Object.copySync
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:106001
  
  - envinfo.js:1 Object.t.writeSync.e [as writeSync]
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:123499
  
  - envinfo.js:1 
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124274
  
  - envinfo.js:1 Promise.all.then.e
    [lib]/[gatsby-cli]/[envinfo]/dist/envinfo.js:1:124289
  
  - util.js:16 tryCatcher
    [lib]/[gatsby-cli]/[bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:512:31
  
  - promise.js:569 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:569:18
  
  - promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18
  
  - promise.js:638 Promise._fulfill
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:638:18
  
  - promise_array.js:126 PromiseArray._resolve
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:126:19
  
  - promise_array.js:144 PromiseArray._promiseFulfilled
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise_array.js:144:14
  
  - promise.js:574 Promise._settlePromise
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:574:26
  
  - promise.js:614 Promise._settlePromise0
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:614:10
  
  - promise.js:694 Promise._settlePromises
    [lib]/[gatsby-cli]/[bluebird]/js/release/promise.js:694:18

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 12
  • Comments: 16 (6 by maintainers)

Most upvoted comments

This is a dependency issue. You need gatsby 2.0.33 or later.

I ran into this similar error today and I deleted all my node modules & package-lock.json, ran npm install again, and that seemed to fix the issue. I am not entirely sure why that worked but it was a workaround that allowed me to keep moving on the tutorial. I hope that helps!

The issue was that I was on an older version of Gatsby. I was on 2.0.19.

Running a yarn add gatsby put me up to the new version.

I think I might have accidentally put it back by installing a separate package. Either way, it’s what did the trick. Make sure you check your package.json file to see if your version of gatsby is over 2.0.33 like @stefanprobst said.

Cheers guys ☕

simple npm update solved this.

I’ll conclude this issue as a dependency error! Thanks for the help everyone.

As a side note, would it be possible to update the gatsby version on the tutorial as well? I’m sure I’m not going to be the last one to have this issue if the version on the tutorial stays the same. 🤔

@elebumm Now is solved. I’m using 2.0.33 and now we have a solution for the issue I reference above. I’m finally able to run develop, build and deploy to Netlify. I appreciate the help!

Thanks guys. npm update solved this.

Running with the same issue using Netlify. Site builds correctly in my local but on Netlify I’m getting this error:

...
9:21:35 PM: Executing user command: gatsby build
9:21:37 PM: success open and validate gatsby-configs — 0.006 s
9:21:37 PM: success load plugins — 0.181 s
9:21:38 PM: success onPreInit — 0.866 s
9:21:38 PM: success delete html and css files from previous builds — 0.085 s
9:21:38 PM: success initialize cache — 0.007 s
9:21:38 PM: success copy gatsby files — 0.020 s
9:21:38 PM: success onPreBootstrap — 0.010 s
9:21:38 PM: success source and transform nodes — 0.199 s
9:21:38 PM: success building schema — 0.264 s
9:21:38 PM: success createPages — 0.057 s
9:21:38 PM: success createPagesStatefully — 0.012 s
9:21:38 PM: error Plugin gatsby-transformer-sharp returned an error
9:21:38 PM: 
9:21:38 PM:   TypeError: getNodesByType is not a function
9:21:38 PM:   
9:21:38 PM:   - gatsby-node.js:22 Object.<anonymous>
9:21:38 PM:     [repo]/[gatsby-transformer-sharp]/gatsby-node.js:22:9
9:21:38 PM:   
9:21:38 PM:   - Generator.next
9:21:38 PM:   
9:21:38 PM:   - debuggability.js:313 Promise._execute
9:21:38 PM:     [repo]/[bluebird]/js/release/debuggability.js:313:9
9:21:38 PM:   
9:21:38 PM:   - promise.js:483 Promise._resolveFromExecutor
9:21:38 PM:     [repo]/[bluebird]/js/release/promise.js:483:18
9:21:38 PM:   
9:21:38 PM:   - promise.js:79 new Promise
9:21:38 PM:     [repo]/[bluebird]/js/release/promise.js:79:10
9:21:38 PM:   
9:21:38 PM:   - gatsby-node.js:31 Object.onPreExtractQueries
9:21:39 PM:     [repo]/[gatsby-transformer-sharp]/gatsby-node.js:31:17
9:21:39 PM:   
9:21:39 PM:   - api-runner-node.js:150 runAPI
9:21:39 PM:     [repo]/[gatsby]/dist/utils/api-runner-node.js:150:37
9:21:39 PM:   
9:21:39 PM:   - api-runner-node.js:254 resolve
9:21:39 PM:     [repo]/[gatsby]/dist/utils/api-runner-node.js:254:19
9:21:39 PM:   
9:21:39 PM:   - debuggability.js:313 Promise._execute
9:21:39 PM:     [repo]/[bluebird]/js/release/debuggability.js:313:9
9:21:39 PM:   
9:21:39 PM:   - promise.js:483 Promise._resolveFromExecutor
9:21:39 PM:     [repo]/[bluebird]/js/release/promise.js:483:18
9:21:39 PM:   
9:21:39 PM:   - promise.js:79 new Promise
9:21:39 PM:     [repo]/[bluebird]/js/release/promise.js:79:10
9:21:39 PM:   
9:21:39 PM:   - api-runner-node.js:253 Promise.mapSeries.plugin
9:21:39 PM:     [repo]/[gatsby]/dist/utils/api-runner-node.js:253:16
9:21:39 PM:   
9:21:39 PM: 
...