Build works locally but deploy fails when pushed to github

Hello everyone. I haven’t worked on my personal portfolio site in a while, needless to say I’m rusty on deploying my changes. Site is built with React + Gatsby, and I can get it working on my local device but it seems like my builds always fail after pushing the code to Github.

The site is https://danny-meuse.netlify.app/

Here is the build log, let me know if you need any other information:

9:23:49 PM: build-image version: c0621868af5001023389eeaa9dbfbbaf313f67e2 (focal)
9:23:49 PM: buildbot version: c0621868af5001023389eeaa9dbfbbaf313f67e2
9:23:49 PM: Fetching cached dependencies
9:23:49 PM: Failed to fetch cache, continuing with build
9:23:49 PM: Starting to prepare the repo for build
9:23:49 PM: No cached dependencies found. Cloning fresh repo
9:23:49 PM: git clone --filter=blob:none GitHub - dannyissocool/gatsby-themed-portfolio
9:23:49 PM: Preparing Git Reference refs/heads/main
9:23:50 PM: Parsing package.json dependencies
9:23:51 PM: Starting build script
9:23:51 PM: Installing dependencies
9:23:51 PM: Python version set to 2.7
9:23:52 PM: v16.19.1 is already installed.
9:23:52 PM: Now using node v16.19.1 (npm v8.19.3)
9:23:52 PM: Enabling Node.js Corepack
9:23:52 PM: Started restoring cached build plugins
9:23:52 PM: Finished restoring cached build plugins
9:23:52 PM: Attempting Ruby version 2.7.2, read from environment
9:23:53 PM: Using Ruby version 2.7.2
9:23:53 PM: Using PHP version 8.0
9:23:53 PM: Started restoring cached corepack dependencies
9:23:53 PM: Finished restoring cached corepack dependencies
9:23:53 PM: No npm workspaces detected
9:23:53 PM: Started restoring cached node modules
9:23:53 PM: Finished restoring cached node modules
9:23:54 PM: Installing npm packages using npm version 8.19.3
9:23:56 PM: npm ERR! code ERESOLVE
9:23:56 PM: npm ERR! ERESOLVE could not resolve
9:23:56 PM: npm ERR!
9:23:56 PM: npm ERR! While resolving: gatsby-plugin-react-helmet@5.0.0
9:23:56 PM: npm ERR! Found: gatsby@3.14.0
9:23:56 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1 (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
9:23:56 PM: npm ERR! node_modules/gatsby
9:23:56 PM: npm ERR! gatsby@“^3.13.1” from the root project
9:23:56 PM: npm ERR! peer gatsby@“^3.0.0-next.0” from babel-plugin-remove-graphql-queries@3.14.0
9:23:56 PM: npm ERR! node_modules/babel-plugin-remove-graphql-queries
9:23:56 PM: npm ERR! babel-plugin-remove-graphql-queries@“^3.14.0” from gatsby@3.14.0
9:23:56 PM: npm ERR! babel-plugin-remove-graphql-queries@“^3.14.0” from gatsby-plugin-image@1.14.0
9:23:56 PM: npm ERR! node_modules/gatsby-plugin-image
9:23:56 PM: npm ERR! gatsby-plugin-image@“^1.14.0” from the root project
9:23:56 PM: npm ERR! 1 more (gbimage-bridge)
9:23:56 PM: npm ERR! 1 more (gatsby-plugin-typescript)
9:23:56 PM: npm ERR! 12 more (gatsby-background-image, gatsby-plugin-image, …)
9:23:56 PM: npm ERR!
9:23:56 PM: npm ERR! Could not resolve dependency:
9:23:56 PM: npm ERR! peer gatsby@“^4.0.0-next” from gatsby-plugin-react-helmet@5.0.0
9:23:56 PM: npm ERR! node_modules/gatsby-plugin-react-helmet
9:23:56 PM: npm ERR! gatsby-plugin-react-helmet@“^5.0.0” from the root project
9:23:56 PM: npm ERR!
9:23:56 PM: npm ERR! Conflicting peer dependency: gatsby@4.25.5
9:23:56 PM: npm ERR! node_modules/gatsby
9:23:56 PM: npm ERR! peer gatsby@“^4.0.0-next” from gatsby-plugin-react-helmet@5.0.0
9:23:56 PM: npm ERR! node_modules/gatsby-plugin-react-helmet
9:23:56 PM: npm ERR! gatsby-plugin-react-helmet@“^5.0.0” from the root project
9:23:56 PM: npm ERR!
9:23:56 PM: npm ERR! Fix the upstream dependency conflict, or retry
9:23:56 PM: npm ERR! this command with --force, or --legacy-peer-deps
9:23:56 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
9:23:56 PM: npm ERR!
9:23:56 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
9:23:56 PM: npm ERR! A complete log of this run can be found in:
9:23:56 PM: npm ERR! /opt/buildhome/.npm/_logs/2023-02-28T05_23_54_295Z-debug-0.log
9:23:56 PM: Error during npm install
9:23:56 PM: Build was terminated: Build script returned non-zero exit code: 1
9:23:56 PM: Failing build: Failed to build site
9:23:56 PM: Finished processing build request in 7.408s

You’ve got conflicting peer dependencies, see this related answer:

This worked, thank you Nathan!

Is there a command I can possibly run to update all my dependencies? Seems like a lot of my packages are outdated if I’m reading my build log correctly.

I’d approach this task (updating dependencies) in two ways, @dannyissocool . In answering your direct question, the fix may not improve the situation, so I don’t necessarily recommend doing this, but the beauty of git is that you can revert back to the current setup if the new one works worse and you don’t feel like debugging it.

  1. This is one way to do what you asked: Update All Node Packages to Latest | by Zack Hoherchak | Subjective Developer | Medium .

  2. To make Netlify use that updated list, once you can build locally with that updated list you’ve created locally, you’ll need to commit your package.json and package-lock.json to the repo so we’ll try to build with it.

This is also some good reading as you mess with dependency versions, around syncing your netlify and local versions of things like node and npm: [Support Guide] Debugging Netlify site builds - this will set you up for better future success around building here in general :slight_smile:

Awesome reply, thank you fool! I will take a look at your Support Guide and go from there. Really appreciate both of you responding. Cheers!

Thanks for stopping by and I’m glad our community and our team could help you answer your outstanding questions! (: