Deploy failed on build with exit code 1

Hi I’m a designer with some web development experience and I’m helping a friend that is having issue with deploying a website that has been made with gatsby and netilfy.
I checked the deploy log and it seems that there’s an issue with a gatsby plugin, however I haven’t been able to identify in the code where the issue is.

this is the deploy log and screenshot of deploy settings, could you help me understand where is the issue?

3:56:26 PM: Netlify Build                                                 
3:56:26 PM: ────────────────────────────────────────────────────────────────
3:56:26 PM: ​
3:56:26 PM: ❯ Version
3:56:26 PM:   @netlify/build 29.54.5
3:56:26 PM: ​
3:56:26 PM: ❯ Flags
3:56:26 PM:   accountId: 5edf78184fb2ac6f013a1b2d
3:56:26 PM:   baseRelDir: true
3:56:26 PM:   buildId: 66f6b8fdcde35b6432bbc677
3:56:26 PM:   deployId: 66f6b8fdcde35b6432bbc679
3:56:26 PM: ​
3:56:26 PM: ❯ Current directory
3:56:26 PM:   /opt/build/repo
3:56:26 PM: ​
3:56:26 PM: ❯ Config file
3:56:26 PM:   /opt/build/repo/netlify.toml
3:56:26 PM: ​
3:56:26 PM: ❯ Context
3:56:26 PM:   production
3:56:26 PM: ​
3:56:26 PM: ❯ Installing plugins
3:56:26 PM:    - @netlify/plugin-gatsby@1
3:56:26 PM:    - netlify-plugin-gatsby-cache@0.3.0
3:56:33 PM: ​
3:56:33 PM: ❯ Loading plugins
3:56:33 PM:    - @netlify/plugin-gatsby@1.0.3 from Netlify app
3:56:33 PM:    - netlify-plugin-gatsby-cache@0.3.0 from netlify.toml
3:56:33 PM: ​
3:56:33 PM: ❯ Outdated plugins
3:56:33 PM:    - @netlify/plugin-gatsby@1.0.3: latest version is 3.8.1
3:56:33 PM:      Migration guide: https://ntl.fyi/gatsby-plugin-migration
3:56:33 PM:      To upgrade this plugin, please uninstall and re-install it from the Netlify plugins directory (https://app.netlify.com/plugins)
3:56:35 PM: No Gatsby cache found. Building fresh.
3:56:35 PM: Add `gatsby-plugin-netlify` to `gatsby-config.js` if you would like to support Gatsby redirects. 🎉
3:56:35 PM: The plugin 'netlify-plugin-gatsby-cache' is no longer required and should be removed.
3:56:35 PM: No Gatsby cache found. Building fresh.
3:56:35 PM: ​
3:56:35 PM: Build command from Netlify app                                
3:56:35 PM: ────────────────────────────────────────────────────────────────
3:56:35 PM: ​
3:56:35 PM: $ gatsby build
3:56:38 PM: success open and validate gatsby-configs - 0.074s
3:56:39 PM: success load plugins - 0.480s
3:56:39 PM: success onPreInit - 0.052s
3:56:39 PM: success delete html and css files from previous builds - 0.002s
3:56:39 PM: success initialize cache - 0.004s
3:56:39 PM: success copy gatsby files - 0.046s
3:56:39 PM: success onPreBootstrap - 0.012s
3:56:39 PM: success gatsby-source-prismic - create types - 0.003s
3:56:39 PM: success createSchemaCustomization - 0.007s
3:56:40 PM: success gatsby-source-prismic - fetch documents - 0.767s
3:56:40 PM: success gatsby-source-prismic - create nodes - 0.448s
3:56:40 PM: success gatsby-source-prismic - write out type paths - 0.005s
3:56:40 PM: success Checking for changed pages - 0.000s
3:56:40 PM: success source and transform nodes - 1.306s
3:56:41 PM: success building schema - 0.741s
3:56:41 PM: info Total nodes: 881, SitePage nodes: 78 (use --verbose for breakdown)
3:56:41 PM: success createPages - 0.199s
3:56:41 PM: success Checking for changed pages - 0.000s
3:56:41 PM: success createPagesStatefully - 0.056s
3:56:41 PM: success update schema - 0.058s
3:56:41 PM: success onPreExtractQueries - 0.001s
3:56:46 PM: success extract queries from components - 4.308s
3:56:46 PM: success write out redirect data - 0.002s
3:56:46 PM: success Build manifest and related icons - 0.172s
3:56:46 PM: success onPostBootstrap - 0.174s
3:56:46 PM: info bootstrap finished - 10.645s
3:56:46 PM: success run static queries - 0.025s - 3/3 119.47/s
3:56:46 PM: success run page queries - 0.308s - 89/89 288.88/s
3:56:46 PM: success write out requires - 0.002s
3:56:47 PM: warning `isModuleDeclaration` has been deprecated, please migrate to `isImportOrExportDeclaration`
3:56:47 PM:     at isModuleDeclaration (/opt/build/repo/node_modules/@babel/types/lib/validators/generated/index.js:2748:35)
3:56:47 PM:     at PluginPass.Program (/opt/build/repo/node_modules/babel-plugin-lodash/lib/index.js:102:44)
3:57:11 PM: failed Building production JavaScript and CSS bundles - 24.679s
3:57:11 PM: error Generating JavaScript bundles failed
3:57:11 PM: Unexpected token (1947:29)
3:57:12 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
3:57:12 PM: ​
3:57:12 PM: "build.command" failed                                        
3:57:12 PM: ────────────────────────────────────────────────────────────────
3:57:12 PM: ​
3:57:12 PM:   Error message
3:57:12 PM:   Command failed with exit code 1: gatsby build (https://ntl.fyi/exit-code-1)
3:57:12 PM: ​
3:57:12 PM:   Error location
3:57:12 PM:   In Build command from Netlify app:
3:57:12 PM:   gatsby build
3:57:12 PM: ​
3:57:12 PM:   Resolved config
3:57:12 PM:   build:
3:57:12 PM:     command: gatsby build
3:57:12 PM:     commandOrigin: ui
3:57:12 PM:     environment:
3:57:12 PM:       - API_KEY
3:57:12 PM:       - CI
3:57:12 PM:     publish: /opt/build/repo/public
3:57:12 PM:     publishOrigin: config
3:57:12 PM:   headers:
3:57:12 PM:     - for: /*
      values:
        Content-Security-Policy: 'default-src data: ''unsafe-inline'' ''unsafe-eval'' https:; script-src data: ''unsafe-inline'' ''unsafe-eval'' https: blob:; style-src data: ''unsafe-inline'' https:; img-src data: https: blob:; font-src data: https:; connect-src https: wss: blob:; media-src https: blob:; object-src https:; child-src https: data: blob:; form-action https:; block-all-mixed-content'
        Feature-Policy: microphone 'none'; geolocation 'none'
        Referrer-Policy: no-referrer
        Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
        X-Content-Type-Options: nosniff
        X-Frame-Options: DENY
  headersOrigin: config
  plugins:
    - inputs: {}
      origin: ui
      package: '@netlify/plugin-gatsby'
    - inputs: {}
      origin: config
      package: netlify-plugin-gatsby-cache
3:57:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:57:12 PM: Failing build: Failed to build site
3:57:12 PM: Finished processing build request in 2m18.44s

@aieio What happens when the Build command of gatsby build is run locally?

@nathanmartin I run the command gatsby build on the terminal in my local folder where I cloned the project but I get this zsh: command not found: gatsby

@aieio If you’ve done a fresh clone of the project and haven’t already been working with it, then you would need to install the dependencies.

This would typically be npm install or yarn install depending on what your project uses.

@nathanmartin I did npm install and tried againgatsby build but I got the same error.
I noticed that in the repository, there are both a package-lock.json and a yarn.lock so I tried to do also a yarn install but then I got a zsh: command not found: yarn

@aieio Is there a public repository for the project?

@nathanmartin the repository is private unfortunately

@aieio That’s no problem, but it does mean there’s not much more I can do for you.

I don’t assist with private projects as explained here.

Your inability to run the project locally is unrelated to Netlify, so you’ll need to puzzle that out yourself.

Once you can confirm that it runs correctly locally, then you can expect it to run on Netlify.