Build fails after adding Netlify CMS

My builds started failing after installing Netlify CMS. Doesn’t seem to like something about the redirect in the netlify.toml file. Any idea what’s going on?

Site: https://kind-booth-f1f950.netlify.app/

netlify.toml:
[[redirects]]
from = “/togetherrising”
to = “https://app.mobilecause.com/public/peer_fundraisers/558743/peer_fundraiser_donations/new?vid=8l14i
status = 301

Netlify log:
10:52:17 PM: Build ready to start

10:52:18 PM: build-image version: 30f629161c0736b1a3ecd8b418e5eeffab5c0faf

10:52:18 PM: build-image tag: v3.3.14

10:52:18 PM: buildbot version: 80b5e22571e5cc4a3ded879ff356be5e92200072

10:52:19 PM: Fetching cached dependencies

10:52:19 PM: Starting to download cache of 143.8MB

10:52:19 PM: Finished downloading cache in 771.027581ms

10:52:19 PM: Starting to extract cache

10:52:26 PM: Finished extracting cache in 6.721133702s

10:52:26 PM: Finished fetching cache in 7.583641927s

10:52:26 PM: Starting to prepare the repo for build

10:52:27 PM: Preparing Git Reference pull/13/head

10:52:28 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI

10:52:28 PM: Starting build script

10:52:28 PM: Installing dependencies

10:52:29 PM: Started restoring cached node version

10:52:31 PM: Finished restoring cached node version

10:52:32 PM: v10.20.1 is already installed.

10:52:33 PM: Now using node v10.20.1 (npm v6.14.4)

10:52:33 PM: Started restoring cached build plugins

10:52:33 PM: Finished restoring cached build plugins

10:52:33 PM: Attempting ruby version 2.6.2, read from environment

10:52:34 PM: Using ruby version 2.6.2

10:52:35 PM: Using PHP version 5.6

10:52:35 PM: 5.2 is already installed.

10:52:35 PM: Using Swift version 5.2

10:52:35 PM: Started restoring cached node modules

10:52:35 PM: Finished restoring cached node modules

10:52:35 PM: Started restoring cached yarn cache

10:52:35 PM: Finished restoring cached yarn cache

10:52:36 PM: Installing NPM modules using Yarn version 1.17.0

10:52:36 PM: yarn install v1.17.0

10:52:36 PM: [1/4] Resolving packages...

10:52:38 PM: [2/4] Fetching packages...

10:53:05 PM: info fsevents@2.1.3: The platform "linux" is incompatible with this module.

10:53:05 PM: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.

10:53:05 PM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.

10:53:05 PM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.

10:53:05 PM: [3/4] Linking dependencies...

10:53:05 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.3.3" has incorrect peer dependency "react-refresh@^0.8.2".

10:53:05 PM: warning "gatsby > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".

10:53:05 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "gatsby@2.6.0".

10:53:05 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "react@16.8.1".

10:53:05 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "react-dom@16.8.1".

10:53:05 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "yup@^0.27.0".

10:53:05 PM: warning "gatsby-plugin-sass > sass-loader@7.3.1" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".

10:53:23 PM: [4/4] Building fresh packages...

10:53:34 PM: Done in 58.12s.

10:53:34 PM: NPM modules installed using Yarn

10:53:35 PM: Started restoring cached go cache

10:53:35 PM: Finished restoring cached go cache

10:53:35 PM: go version go1.12 linux/amd64

10:53:35 PM: go version go1.12 linux/amd64

10:53:35 PM: Installing missing commands

10:53:35 PM: Verify run directory

10:53:36 PM: ​

10:53:36 PM: ┌─────────────────────────────┐

10:53:36 PM: │ Netlify Build │

10:53:36 PM: └─────────────────────────────┘

10:53:36 PM: ​

10:53:36 PM: ❯ Version

10:53:36 PM: @netlify/build 1.0.14

10:53:36 PM: ​

10:53:36 PM: ❯ Flags

10:53:36 PM: mode: buildbot

10:53:36 PM: ​

10:53:36 PM: ❯ Current directory

10:53:36 PM: /opt/build/repo

10:53:36 PM: ​

10:53:36 PM: ❯ Config file

10:53:36 PM: /opt/build/repo/netlify.toml

10:53:36 PM: ​

10:53:36 PM: ❯ Context

10:53:36 PM: deploy-preview

10:53:37 PM: ​

10:53:37 PM: ┌────────────────────────────────────┐

10:53:37 PM: │ 1. build.command from netlify.toml │

10:53:37 PM: └────────────────────────────────────┘

10:53:37 PM: ​

10:53:37 PM: $ gatsby build

10:53:39 PM:

10:53:39 PM:

10:53:39 PM: success open and validate gatsby-configs - 0.041s

10:53:40 PM:

10:53:40 PM: success load plugins - 0.939s

10:53:40 PM:

10:53:40 PM: success onPreInit - 0.021s

10:53:40 PM: success delete html and css files from previous builds - 0.021s

10:53:40 PM:

10:53:40 PM: success initialize cache - 0.049s

10:53:40 PM:

10:53:40 PM: success copy gatsby files - 0.048s

10:53:41 PM:

10:53:41 PM: success onPreBootstrap - 0.181s

10:53:41 PM:

10:53:41 PM: success createSchemaCustomization - 0.007s

10:53:41 PM:

10:53:41 PM: success source and transform nodes - 0.094s

10:53:41 PM:

10:53:41 PM: success building schema - 0.292s

10:53:41 PM:

10:53:41 PM: success createPages - 0.000s

10:53:41 PM: success createPagesStatefully - 0.068s

10:53:41 PM: success onPreExtractQueries - 0.000s

10:53:41 PM: success update schema - 0.019s

10:53:41 PM: success extract queries from components - 0.331s

10:53:41 PM:

10:53:41 PM: success write out requires - 0.003s

10:53:41 PM:

10:53:41 PM: success write out redirect data - 0.001s

10:53:41 PM:

10:53:41 PM: warning The icon(src/images/icon-heart-eyes-favicon.svg) you provided to 'gatsby-plugin-manifest' is not square.

10:53:41 PM: The icons we generate will be square and for the best results we recommend you provide a square icon.

10:53:42 PM:

10:53:42 PM: success Build manifest and related icons - 0.243s

10:53:42 PM:

10:53:42 PM: success onPostBootstrap - 0.245s

10:53:42 PM:

10:53:42 PM:

10:53:42 PM: ⠀

10:53:42 PM:

10:53:42 PM:

10:53:42 PM: info bootstrap finished - 5.121s

10:53:42 PM:

10:53:42 PM:

10:53:42 PM: ⠀

10:53:54 PM: success Building production JavaScript and CSS bundles - 11.980s

10:53:54 PM:

10:53:54 PM: success Rewriting compilation hashes - 0.002s

10:53:54 PM:

10:53:54 PM:

10:53:54 PM: success run queries - 12.147s - 6/6 0.49/s

10:53:57 PM:

10:53:57 PM: failed Building static HTML for pages - 2.710s

10:53:57 PM:

10:53:57 PM:

10:53:57 PM: error Building static HTML failed

10:53:57 PM:

10:53:57 PM:

10:53:57 PM:

10:53:57 PM: WebpackError: Module build failed (from ./node_modules/gatsby/dist/utils/babel -loader.js):

10:53:57 PM:

10:53:57 PM: - build-html.js:110 doBuildPages

10:53:57 PM: [repo]/[gatsby]/dist/commands/build-html.js:110:24

10:53:57 PM:

10:53:57 PM:

10:53:57 PM: ​

10:53:57 PM: ┌─────────────────────────────┐

10:53:57 PM: │ "build.command" failed │

10:53:57 PM: └─────────────────────────────┘

10:53:57 PM: ​

10:53:57 PM: Error message

10:53:57 PM: Command failed with exit code 1: gatsby build

10:53:57 PM: ​

10:53:57 PM: Error location

10:53:57 PM: In build.command from netlify.toml:

10:53:57 PM: gatsby build

10:53:57 PM: ​

10:53:57 PM: Resolved config

10:53:57 PM: build:

10:53:57 PM: command: gatsby build

10:53:57 PM: publish: /opt/build/repo/public

10:53:57 PM: redirects:

10:53:57 PM: - from: /togetherrising

10:53:57 PM: status: 301

10:53:57 PM: to: 'https://app.mobilecause.com/public/peer_fundraisers/558743/peer_fundraiser_donations/new?vid=8l14i'

10:53:57 PM: Caching artifacts

10:53:57 PM: Started saving node modules

10:53:57 PM: Finished saving node modules

10:53:57 PM: Started saving build plugins

10:53:57 PM: Finished saving build plugins

10:53:57 PM: Started saving yarn cache

10:53:57 PM: Finished saving yarn cache

10:53:57 PM: Started saving pip cache

10:53:57 PM: Finished saving pip cache

10:53:57 PM: Started saving emacs cask dependencies

10:53:57 PM: Finished saving emacs cask dependencies

10:53:57 PM: Started saving maven dependencies

10:53:57 PM: Finished saving maven dependencies

10:53:57 PM: Started saving boot dependencies

10:53:58 PM: Finished saving boot dependencies

10:53:58 PM: Started saving go dependencies

10:53:58 PM: Finished saving go dependencies

10:53:58 PM: Error running command: Build script returned non-zero exit code: 1

10:53:58 PM: Failing build: Failed to build site

10:53:58 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1

10:53:58 PM: Finished processing build request in 1m39.158542044s

Solved. Needed to have this script:

if (window.netlifyIdentity) {
      window.netlifyIdentity.on('init', user => {
        if (!user) {
          window.netlifyIdentity.on('login', () => {
            document.location.href = '/admin/'
          })
        }
      })
    }

in a useEffect hook.

1 Like

Many thanks for sharing your fix :trophy: