Gatsby Build Failing but passing before

site name: ksett
site owner: ksett.co
Build command: gatsby build
Publish directory: public/

Site worked before but first deploy in months and now it’s broken. The repo has no netlify.toml file and package.json is in the root directory.

So not completely sure why the site isn’t being recognized as a gatsby site.

Init:

5:34:08 PM: Build ready to start
5:34:10 PM: build-image version: 3031d4c9e432fd7016f6279fc9ad706f9205d845
5:34:10 PM: build-image tag: v3.3.17
5:34:10 PM: buildbot version: da42b14a989873e00cc6f36bc354c01953474181
5:34:10 PM: Fetching cached dependencies
5:34:10 PM: Starting to download cache of 254.2KB
5:34:10 PM: Finished downloading cache in 58.663175ms
5:34:10 PM: Starting to extract cache
5:34:10 PM: Failed to fetch cache, continuing with build
5:34:10 PM: Starting to prepare the repo for build
5:34:11 PM: No cached dependencies found. Cloning fresh repo
5:34:11 PM: git clone https://github.com/ksett-co/ksett_web
5:34:12 PM: Preparing Git Reference refs/heads/master
5:34:13 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
5:34:13 PM: Starting build script
5:34:13 PM: Installing dependencies
5:34:13 PM: Python version set to 2.7
5:34:14 PM: v12.18.0 is already installed.
5:34:14 PM: Now using node v12.18.0 (npm v6.14.4)
5:34:14 PM: Started restoring cached build plugins
5:34:14 PM: Finished restoring cached build plugins
5:34:15 PM: Attempting ruby version 2.7.1, read from environment
5:34:16 PM: Using ruby version 2.7.1
5:34:16 PM: Using PHP version 5.6
5:34:16 PM: 5.2 is already installed.
5:34:16 PM: Using Swift version 5.2
5:34:16 PM: Started restoring cached node modules
5:34:16 PM: Finished restoring cached node modules
5:34:16 PM: Started restoring cached yarn cache
5:34:16 PM: Finished restoring cached yarn cache
5:34:16 PM: Installing yarn at version 1.22.4
5:34:16 PM: Installing Yarn!
5:34:16 PM: > Downloading tarball...
5:34:18 PM: > Extracting to ~/.yarn...
5:34:18 PM: > Adding to $PATH...
5:34:18 PM: > Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.
5:34:18 PM: Installing NPM modules using Yarn version 1.22.4
5:34:19 PM: yarn install v1.22.4
5:34:19 PM: [1/4] Resolving packages...
5:34:20 PM: [2/4] Fetching packages...
5:34:38 PM: info fsevents@2.1.3: The platform "linux" is incompatible with this module.
5:34:38 PM: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
5:34:38 PM: [3/4] Linking dependencies...
5:34:38 PM: warning " > gatsby-plugin-google-analytics@2.3.4" has unmet peer dependency "gatsby@^2.0.0".
5:34:38 PM: warning " > gatsby-plugin-manifest@2.4.12" has unmet peer dependency "gatsby@^2.4.0".
5:34:38 PM: warning " > gatsby-plugin-offline@3.2.11" has unmet peer dependency "gatsby@^2.4.0".
5:34:38 PM: warning " > gatsby-plugin-react-helmet@3.3.4" has unmet peer dependency "gatsby@^2.0.0".
5:34:38 PM: warning " > gatsby-plugin-sharp@2.6.12" has unmet peer dependency "gatsby@>2.0.15".
5:34:38 PM: warning " > gatsby-source-filesystem@2.3.12" has unmet peer dependency "gatsby@^2.2.0".
5:34:38 PM: warning " > gatsby-transformer-sharp@2.5.5" has unmet peer dependency "gatsby@^2.12.1".
5:34:48 PM: [4/4] Building fresh packages...
5:35:08 PM: Done in 49.14s.
5:35:08 PM: NPM modules installed using Yarn
5:35:08 PM: Started restoring cached go cache
5:35:08 PM: Finished restoring cached go cache
5:35:08 PM: go version go1.14.4 linux/amd64
5:35:08 PM: go version go1.14.4 linux/amd64
5:35:08 PM: Installing missing commands
5:35:08 PM: Verify run directory

Build:

5:35:09 PM: ​
5:35:09 PM: ┌─────────────────────────────┐
5:35:09 PM: │        Netlify Build        │
5:35:09 PM: └─────────────────────────────┘
5:35:09 PM: ​
5:35:09 PM: ❯ Version
5:35:09 PM:   @netlify/build 2.0.10
5:35:09 PM: ​
5:35:09 PM: ❯ Flags
5:35:09 PM:   deployId: 5eefe06051dfb93930b4d980
5:35:09 PM:   mode: buildbot
5:35:09 PM: ​
5:35:09 PM: ❯ Current directory
5:35:09 PM:   /opt/build/repo
5:35:09 PM: ​
5:35:09 PM: ❯ Config file
5:35:09 PM:   No config file was defined: using default values.
5:35:09 PM: ​
5:35:09 PM: ❯ Context
5:35:09 PM:   production
5:35:09 PM: ​
5:35:09 PM: ┌────────────────────────────────┐
5:35:09 PM: │ 1. Build command from settings │
5:35:09 PM: └────────────────────────────────┘
5:35:09 PM: ​
5:35:09 PM: $ gatsby build
5:35:11 PM: error gatsby build
5:35:11 PM: Build a Gatsby project.
5:35:11 PM: Options:
5:35:11 PM:   --verbose                   Turn on verbose output  [boolean] [default: false]
5:35:11 PM:   --no-color, --no-colors     Turn off the color in output  [boolean] [default: false]
5:35:11 PM:   --json                      Turn on the JSON logger  [boolean] [default: false]
5:35:11 PM:   --prefix-paths              Build site with link paths prefixed with the pathPrefix value in gatsby-config.js. Default is env.PREFIX_PATHS or false.  [boolean] [default: false]
5:35:11 PM:   --no-uglify                 Build site without uglifying JS bundles (for debugging).  [boolean] [default: false]
5:35:11 PM:   --profile                   Build site with react profiling (this can add some additional overhead). See https://reactjs.org/docs/profiler  [boolean] [default: false]
5:35:11 PM:   --graphql-tracing           Trace every graphql resolver, may have performance implications  [boolean] [default: false]
5:35:11 PM:   --open-tracing-config-file  Tracer configuration file (OpenTracing compatible). See https://gatsby.dev/tracing  [string]
5:35:11 PM:   -h, --help                  Show help  [boolean]
5:35:11 PM:   -v, --version               Show the version of the Gatsby CLI and the Gatsby package in the current project  [boolean]
5:35:11 PM: error gatsby <build> can only be run for a gatsby site.
5:35:11 PM: Either the current working directory does not contain a valid package.json or 'gatsby' is not specified as a dependency
5:35:11 PM: ​
5:35:11 PM: ┌─────────────────────────────┐
5:35:11 PM: │   "build.command" failed    │
5:35:11 PM: └─────────────────────────────┘
5:35:11 PM: ​
5:35:11 PM:   Error message
5:35:11 PM:   Command failed with exit code 1: gatsby build
5:35:11 PM: ​
5:35:11 PM:   Error location
5:35:11 PM:   In Build command from settings:
5:35:11 PM:   gatsby build
5:35:11 PM: ​
5:35:11 PM:   Resolved config
5:35:11 PM:   build:
5:35:11 PM:     command: gatsby build
5:35:11 PM:     publish: /opt/build/repo/public
5:35:11 PM: Caching artifacts
5:35:11 PM: Started saving node modules
5:35:11 PM: Finished saving node modules
5:35:11 PM: Started saving build plugins
5:35:11 PM: Finished saving build plugins
5:35:11 PM: Started saving yarn cache
5:35:11 PM: Finished saving yarn cache
5:35:11 PM: Started saving pip cache
5:35:17 PM: Finished saving pip cache
5:35:17 PM: Started saving emacs cask dependencies
5:35:17 PM: Finished saving emacs cask dependencies
5:35:17 PM: Started saving maven dependencies
5:35:17 PM: Finished saving maven dependencies
5:35:17 PM: Started saving boot dependencies
5:35:17 PM: Finished saving boot dependencies
5:35:17 PM: Started saving go dependencies
5:35:17 PM: Finished saving go dependencies
5:35:20 PM: Error running command: Build script returned non-zero exit code: 1
5:35:20 PM: Failing build: Failed to build site
5:35:20 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
5:35:20 PM: Finished processing build request in 1m9.744045841s

Main Error:

5:35:11 PM: error gatsby <build> can only be run for a gatsby site.
    5:35:11 PM: Either the current working directory does not contain a valid package.json or 'gatsby' is not specified as a dependency
    5:35:11 PM: ​
    5:35:11 PM: ┌─────────────────────────────┐
    5:35:11 PM: │   "build.command" failed    │
    5:35:11 PM: └─────────────────────────────┘
    5:35:11 PM: ​
    5:35:11 PM:   Error message
    5:35:11 PM:   Command failed with exit code 1: gatsby build

Resolved.

Issue was using gatsby-cli instead of gatsby npm package as build command.

1 Like