Need guidance on updating Gatsby to newer version (Update the version of Gatsby to at least `3.9.0`)

So I apologize in advance, this might be something extremely simple and I’m either too dumb or overhtinking.

I came on to help my friends with their tequila company website (https://www.drinkcelaya.com).
-I’ve been able to use github and xcode to make changes to the site as needed, commit the changed files, and deploy. 90% of the time i’ve been successful, aside from the random clear cache and retry or fat finger a bracket.

BUT, now the issue has been (for the last 6 months), I can’t update the site due to outdated plugins (based on the errors, and response from netlify, can provide more if necessary).

Looking online, it seems simple, “just update gatsby” and a few short commands…
But WHERE/HOW? I dont know if netflify has a cli built into the site…i installed netflify CLI on my laptop (and NPM), ran the command locally to upgrade Gatsby (not sure if its good or bad) but no changed on github in terms of updated files or plugins. Even pushed a deploy and yep, same failure.
(I’m sure theres a missing step to securely connect to the netlify site from my laptop cli but again, missing steps here and there)

I’m likely missing something very stupid, and my apologies, I’m linux and overall tech savvy, but never got too deep into the web deployment realm so working on this site has been alot of fun, but I just cant update the thing so it can deploy (and i need to update shipping zip codes and the store locator and the headers and footer, but cant resolve the deployment and plugin depracation. So im completely stuck and have been for months.

ANY assistance is greatly appreciated, I assume I have to be in the right place to run the cli commands and then push the update and then deploy with success, so if anyone has a walk through or some forum hand holding or ELI5 information, I dont want to crash the site and even have a staging option too.

Deploy error:
6:20:31 PM: $ npm run build
6:20:31 PM: > blog-with-gatsby-web@1.0.7 build
6:20:31 PM: > gatsby build
6:20:33 PM: error (node:7269) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
6:20:33 PM: (Use node --trace-deprecation ... to show where the warning was created)
6:20:33 PM: error Your plugins must export known APIs from their gatsby-node.js.
6:20:33 PM: See Gatsby Node APIs | Gatsby for the list of Gatsby node APIs.
6:20:33 PM: - The plugin gatsby-source-shopify@7.13.0 is using the API “onPluginInit” which was introduced in gatsby@3.9.0.
6:20:33 PM: Some of the following may help fix the error(s):
6:20:33 PM: - npm install gatsby@^3.9.0
6:20:33 PM: - Rename “onPluginInit” → “unstable_onPluginInit”
6:20:33 PM: success open and validate gatsby-configs, load plugins - 0.686s
6:20:33 PM: success onPreInit - 0.002s
6:20:33 PM: info [sanity] Fetching remote GraphQL schema
6:20:34 PM: info [sanity] Transforming to Gatsby-compatible GraphQL SDL
6:20:34 PM: info [sanity] Stitching GraphQL schemas from SDL
6:20:34 PM: success initialize cache - 0.860s
6:20:34 PM: success copy gatsby files - 0.036s
6:20:34 PM: success Compiling Gatsby Functions - 0.189s
6:20:34 PM: success onPreBootstrap - 0.194s
6:20:34 PM: success createSchemaCustomization - 0.010s
6:20:34 PM: info Running priority queries
6:20:35 PM: error Couldn’t initiate bulk operation query
6:20:35 PM:
6:20:35 PM: Error: query: Invalid bulk query: Field must have selections (field ‘mediaCoun t’ returns Count but has no selections. Did you mean ‘mediaCount { … }’?)
6:20:35 PM:
6:20:35 PM: - source-from-operation.ts:56
6:20:35 PM: [web]/[gatsby-source-shopify]/src/source-from-operation.ts:56:22
6:20:35 PM:
6:20:35 PM: - Array.map
6:20:35 PM:
6:20:35 PM: - source-from-operation.ts:46 sourceFromOperation
6:20:35 PM: [web]/[gatsby-source-shopify]/src/source-from-operation.ts:46:22
6:20:35 PM:
6:20:35 PM: - task_queues:105 processTicksAndRejections
6:20:35 PM: node:internal/process/task_queues:105:5
6:20:35 PM:
6:20:35 PM: - source-nodes.ts:56 Object.sourceNodes
6:20:35 PM: [web]/[gatsby-source-shopify]/src/source-nodes.ts:56:5
6:20:35 PM:
6:20:35 PM: - api-runner-node.js:430 runAPI
6:20:35 PM: [web]/[gatsby]/src/utils/api-runner-node.js:430:16
6:20:35 PM:
6:20:35 PM:
6:20:35 PM: not finished source and transform nodes - 0.783s
6:20:35 PM: not finished source shopify products - 0.708s
6:20:35 PM: ​
6:20:35 PM: “build.command” failed
6:20:35 PM: ────────────────────────────────────────────────────────────────
6:20:35 PM: ​
6:20:35 PM: Error message
6:20:35 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
6:20:35 PM: ​
6:20:35 PM: Error location
6:20:35 PM: In Build command from Netlify app:
6:20:35 PM: npm run build
6:20:35 PM: ​
6:20:35 PM: Resolved config
6:20:35 PM: build:
6:20:35 PM: base: /opt/build/repo/web
6:20:35 PM: command: npm run build
6:20:35 PM: commandOrigin: ui
6:20:35 PM: environment:
6:20:35 PM: - GATSBY_MYSHOPIFY_URL
6:20:35 PM: - GATSBY_SHOPIFY_STORE_URL
6:20:35 PM: - GATSBY_STOREFRONT_ACCESS_TOKEN
6:20:35 PM: - SANITY_DEPLOY_STUDIO_TOKEN
6:20:35 PM: - SHOPIFY_APP_ID
6:20:35 PM: - SHOPIFY_APP_PASSWORD
6:20:35 PM: publish: /opt/build/repo/web/public
6:20:35 PM: publishOrigin: ui
6:20:35 PM: functionsDirectory: /opt/build/repo/web/functions
6:20:39 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
6:20:39 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:20:39 PM: Failing build: Failed to build site
6:20:39 PM: Finished processing build request in 1m9.714s

AI’s response: Diagnosis:

  • The build failed with exit code 1 during the npm run build command.
  • The error indicates that a plugin (gatsby-source-shopify@7.13.0) is using an API (onPluginInit) that was introduced in gatsby@3.9.0, which is causing an error.

Solution:

  1. Update the version of Gatsby to at least 3.9.0 by running:
npm install gatsby@^3.9.0
  1. If renaming is needed, rename "onPluginInit" to "unstable_onPluginInit" as suggested in the error message.

Ensure that the required changes are made in the project configuration to match the API changes in the newer version of Gatsby.

Looking at my package.node yes its old:
“name”: “sanity-gatsby-blog”,
“version”: “1.0.17”,

I tried running again the command npm install gatsby@^3.9.0 locally, and it looks like it went out and grabbed all the newest stuff, but I’m sure theres a disconnect between my local cli and github and the netlify (I tried opening netlify and authorized it to do so via CLI). I may be just missing some really basic stuff (that might help me in the future in terms of best practices and tools and configuration).

I came on way after this project and have had to learn everything as i’ve gone so any assistance is greatly appreciated. Thanks everyone and anyone in advance.

The error seems to be down here and it’s just a guess at this point, but it seems like there’s somethhing wrong with a GraphQL query in your code.

We cannot provide code-level debugging and anyways, Gatsby (as a framework, let alone v3) is almost dead. If it’s possible, I’d recommend switching to a different framework like Next.js or Astro.