Hi,
I am getting the error Build script returned non-zero exit code: 4
on a build task that actually builds correctly.
This exact repo was used to build a website a week ago on another Netlify site and worked correcly with the same env variables and settings.
I know it’s old versions of Node and Gatsby etc. but they still should build and deploy.
Can anyone please help with this?
Log:
10:53:19 PM: build-image version: 3ffff9df3d5419545acc1b673a54de348174406d (focal)
10:53:19 PM: buildbot version: 06bd328e5eb3b6956f9c6602486ecccce8b861a0
10:53:19 PM: Fetching cached dependencies
10:53:19 PM: Failed to fetch cache, continuing with build
10:53:19 PM: Starting to prepare the repo for build
10:53:19 PM: No cached dependencies found. Cloning fresh repo
10:53:20 PM: Preparing Git Reference refs/heads/master
10:53:21 PM: Starting to install dependencies
10:53:21 PM: Python version set to 3.8
10:53:21 PM: Attempting Ruby version 2.7.2, read from environment
10:53:22 PM: Using Ruby version 2.7.2
10:53:23 PM: Started restoring cached go cache
10:53:23 PM: Finished restoring cached go cache
10:53:24 PM: go version go1.19.13 linux/amd64
10:53:24 PM: Using PHP version 8.0
10:53:25 PM: Downloading and installing node v14.21.3...
10:53:26 PM: Downloading https://nodejs.org/dist/v14.21.3/node-v14.21.3-linux-x64.tar.xz...
10:53:26 PM: Computing checksum with sha256sum
10:53:26 PM: Checksums matched!
10:53:28 PM: Now using node v14.21.3 (npm v6.14.18)
10:53:28 PM: Enabling Node.js Corepack
10:53:28 PM: Started restoring cached build plugins
10:53:28 PM: Finished restoring cached build plugins
10:53:28 PM: Started restoring cached corepack dependencies
10:53:28 PM: Finished restoring cached corepack dependencies
10:53:28 PM: Started restoring cached yarn cache
10:53:28 PM: Finished restoring cached yarn cache
10:53:28 PM: No yarn workspaces detected
10:53:28 PM: Started restoring cached node modules
10:53:28 PM: Finished restoring cached node modules
10:53:28 PM: Installing npm packages using Yarn version 1.22.19
10:53:29 PM: yarn install v1.22.19
10:53:29 PM: [1/4] Resolving packages...
10:53:29 PM: [2/4] Fetching packages...
10:53:34 PM: warning url-loader@1.1.2: Invalid bin field for "url-loader".
10:54:00 PM: [3/4] Linking dependencies...
10:54:00 PM: warning "gatsby > @pmmmwh/react-refresh-webpack-plugin@0.3.3" has incorrect peer dependency "react-refresh@^0.8.2".
10:54:00 PM: warning " > babel-loader@8.1.0" has unmet peer dependency "webpack@>=2".
10:54:00 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:54:00 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "gatsby@2.6.0".
10:54:00 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "react@16.8.1".
10:54:00 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "react-dom@16.8.1".
10:54:00 PM: warning "gatsby > gatsby-admin > gatsby-interface@0.0.163" has incorrect peer dependency "yup@^0.27.0".
10:54:00 PM: warning "gatsby-plugin-netlify > webpack-assets-manifest@3.1.1" has unmet peer dependency "webpack@>=4.4.0".
10:54:00 PM: warning " > gatsby-plugin-theme-ui@0.3.0" has incorrect peer dependency "theme-ui@^0.2.0".
10:54:00 PM: warning "@storybook/addon-a11y > @storybook/api@5.3.19" has unmet peer dependency "regenerator-runtime@*".
10:54:00 PM: warning " > eslint-config-gatsby-standard@2.2.0" has incorrect peer dependency "eslint@^5.16.0".
10:54:00 PM: warning "eslint-config-gatsby-standard > eslint-plugin-react@7.19.0" has incorrect peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0".
10:54:28 PM: [4/4] Building fresh packages...
10:54:45 PM: Done in 76.34s.
10:54:45 PM: npm packages installed using Yarn
10:54:45 PM: Successfully installed dependencies
10:54:45 PM: Starting build script
10:54:46 PM: Detected 1 framework(s)
10:54:46 PM: "gatsby" at version "2.22.13"
10:54:46 PM: Section completed: initializing
10:54:48 PM:
10:54:48 PM: Netlify Build
10:54:48 PM: ────────────────────────────────────────────────────────────────
10:54:48 PM:
10:54:48 PM: ❯ Version
10:54:48 PM: @netlify/build 29.31.0
10:54:48 PM:
10:54:48 PM: ❯ Flags
10:54:48 PM: baseRelDir: true
10:54:48 PM: buildId: 6578e45c97fa131d7013e381
10:54:48 PM: deployId: 6578e45c97fa131d7013e383
10:54:48 PM:
10:54:48 PM: ❯ Current directory
10:54:48 PM: /opt/build/repo
10:54:48 PM:
10:54:48 PM: ❯ Config file
10:54:48 PM: No config file was defined: using default values.
10:54:48 PM:
10:54:48 PM: ❯ Context
10:54:48 PM: production
10:54:48 PM:
10:54:48 PM: ❯ Installing plugins
10:54:48 PM: - @netlify/plugin-gatsby@3.8.0
10:55:05 PM:
10:55:05 PM: ❯ Loading plugins
10:55:05 PM: - @netlify/plugin-gatsby@3.8.0 from Netlify app
10:55:06 PM:
10:55:06 PM: @netlify/plugin-gatsby (onPreBuild event)
10:55:06 PM: ────────────────────────────────────────────────────────────────
10:55:06 PM:
10:55:06 PM: No Gatsby cache found. Building fresh.
10:55:06 PM: The plugin `gatsby-plugin-netlify` does not support DSG, please update to >=4.2.0
10:55:06 PM:
10:55:06 PM: (@netlify/plugin-gatsby onPreBuild completed in 12ms)
10:55:06 PM:
10:55:06 PM: Build command from Netlify app
10:55:06 PM: ────────────────────────────────────────────────────────────────
10:55:06 PM:
10:55:06 PM: $ CI="" yarn previewSetup && yarn run build:preview
10:55:06 PM: yarn run v1.22.19
10:55:06 PM: $ cp -f preview.toml netlify.toml
10:55:06 PM: Done in 0.04s.
10:55:07 PM: yarn run v1.22.19
10:55:07 PM: $ gatsby build
10:55:08 PM: success open and validate gatsby-configs - 0.033s
10:55:09 PM: success load plugins - 0.430s
10:55:09 PM: success onPreInit - 0.007s
10:55:09 PM: success delete html and css files from previous builds - 0.008s
10:55:09 PM: success initialize cache - 0.004s
10:55:09 PM: success copy gatsby files - 0.017s
10:55:09 PM: success onPreBootstrap - 0.005s
10:55:09 PM: info Reading GraphQL type definitions from /opt/build/repo/src/gatsby/schema/schema.gql
10:55:09 PM: success createSchemaCustomization - 0.009s
10:55:09 PM: Starting to fetch data from Contentful
10:55:09 PM: info Fetching default locale
10:55:09 PM: info default locale is: en-GB
10:55:10 PM: info contentTypes fetched 10
10:55:10 PM: info Updated entries 67
10:55:10 PM: info Deleted entries 0
10:55:10 PM: info Updated assets 72
10:55:10 PM: info Deleted assets 0
10:55:10 PM: Fetch Contentful data: 657.726ms
10:55:10 PM: success source and transform nodes - 0.920s
10:55:10 PM: success building schema - 0.438s
10:55:10 PM: success createPages - 0.026s
10:55:10 PM: success createPagesStatefully - 0.043s
10:55:10 PM: success onPreExtractQueries - 0.001s
10:55:10 PM: success update schema - 0.015s
10:55:11 PM: success extract queries from components - 0.329s
10:55:11 PM: success write out requires - 0.005s
10:55:11 PM: success write out redirect data - 0.001s
10:55:11 PM: success Build manifest and related icons - 0.138s
10:55:11 PM: success onPostBootstrap - 0.139s
10:55:11 PM: ⠀
10:55:11 PM: info bootstrap finished - 3.998s
10:55:11 PM: ⠀
10:55:11 PM: warning Browserslist: caniuse-lite is outdated. Please run:
10:55:11 PM: npx browserslist@latest --update-db
10:55:29 PM: success Building production JavaScript and CSS bundles - 17.782s
10:55:29 PM: success Rewriting compilation hashes - 0.001s
10:55:29 PM: success run queries - 18.328s - 21/21 1.15/s
10:55:32 PM: success Building static HTML for pages - 2.903s - 13/13 4.48/s
10:55:32 PM: success Generating image thumbnails - 21.273s - 2/2 0.09/s
10:55:32 PM: success onPostBuild - 0.005s
10:55:32 PM: info Done building in 25.291605932 sec
10:55:32 PM: Done in 25.56s.
10:55:32 PM: Unhandled rejection…
10:55:32 PM: TypeError: Cannot read properties of undefined (reading "packageName")
10:55:32 PM: at title (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/error/types.js:281:31)
10:55:32 PM: at getTitle (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/error/parse/parse.js:69:12)
10:55:32 PM: at getFullErrorInfo (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/error/parse/parse.js:14:20)
10:55:32 PM: at logBuildError (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/log/messages/core.js:17:27)
10:55:32 PM: at handleBuildError (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/error/handle.js:17:9)
10:55:32 PM: at async file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/core/main.js:81:34
10:55:32 PM: at async buildSite (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/core/main.js:31:12)
10:55:32 PM: at async runCli (file:///opt/buildhome/node-deps/node_modules/@netlify/build/lib/core/bin.js:22:36)
10:55:32 PM: /opt/buildhome/node-deps/node_modules/.bin/netlify-build exited with exit code 0 without finishing the build.
10:55:33 PM: Build failed due to an internal system error: Build script returned non-zero exit code: 4
10:55:33 PM: Failing build: Failed to build site
10:55:33 PM: Finished processing build request in 2m14.126s
10:55:33 PM: Failed during stage "building site": Build script returned non-zero exit code: 4