Home
Support Forums

Netlify keep failing at buiding when deploying

Hello, so I have been getting build errors every time I try to deploy my app it’s driving me nuts, I am trying to deploy it and continue working on my front-end, I already spent a whole day trying and searching the internet looking for solutions but nothing worked so far,

This is my app name : https://seedingfund.netlify.app

Some solutions I tried :
1- Build: CI= npm run build
2- env variables : CI = false (which worked in past apps I deployed)
3- using netlify-cli then push to gethub and connect to netlify, as above, worked before but not this time.

To make helping me easier I will share my package.json file :

{
  "homepage": "./",
  "name": "seedingfund",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.4.1",
    "@emotion/styled": "^11.3.0",
    "@material-ui/core": "^4.12.3",
    "@mui/icons-material": "^5.0.1",
    "@mui/material": "^5.0.2",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "axios": "^0.22.0",
    "material-ui-icons": "^1.0.0-beta.36",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-loader-spinner": "^4.0.0",
    "react-redux": "^7.2.5",
    "react-router": "^5.2.1",
    "react-router-dom": "^5.3.0",
    "react-scripts": "^1.1.5",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "predeploy": "npm run build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

This is my deploy log with the error:

2:20:25 AM: Build ready to start
2:20:27 AM: build-image version: 081db65c3e4ce8423fedb40e7689a87de6f84667
2:20:27 AM: build-image tag: v4.3.1
2:20:27 AM: buildbot version: 1523fa12d6de79e532ed0aff71973c5fbb8e58aa
2:20:27 AM: Fetching cached dependencies
2:20:27 AM: Failed to fetch cache, continuing with build
2:20:27 AM: Starting to prepare the repo for build
2:20:27 AM: No cached dependencies found. Cloning fresh repo
2:20:27 AM: git clone https://github.com/AmjadMesmar/seedingfund
2:20:28 AM: Preparing Git Reference refs/heads/main
2:20:28 AM: Parsing package.json dependencies
2:20:29 AM: Starting build script
2:20:29 AM: Installing dependencies
2:20:29 AM: Python version set to 2.7
2:20:30 AM: Downloading and installing node v16.10.0...
2:20:30 AM: Downloading https://nodejs.org/dist/v16.10.0/node-v16.10.0-linux-x64.tar.xz...
2:20:30 AM: Computing checksum with sha256sum
2:20:30 AM: Checksums matched!
2:20:33 AM: Now using node v16.10.0 (npm v7.24.0)
2:20:33 AM: Started restoring cached build plugins
2:20:33 AM: Finished restoring cached build plugins
2:20:33 AM: Attempting ruby version 2.7.2, read from environment
2:20:35 AM: Using ruby version 2.7.2
2:20:35 AM: Using PHP version 8.0
2:20:35 AM: Started restoring cached node modules
2:20:35 AM: Finished restoring cached node modules
2:20:35 AM: Installing NPM modules using NPM version 7.24.0
2:20:49 AM: npm WARN deprecated flatten@1.0.3: flatten is deprecated in favor of utility frameworks such as lodash.
2:20:49 AM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
2:20:49 AM: npm WARN deprecated har-validator@5.1.5: this library is no longer supported
2:20:49 AM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
2:20:50 AM: npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
2:20:50 AM: npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
2:20:52 AM: npm WARN deprecated sane@1.6.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
2:20:52 AM: npm WARN deprecated sw-precache@5.2.1: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
2:20:53 AM: npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
2:20:54 AM: npm WARN deprecated sw-toolbox@3.6.0: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
2:20:55 AM: npm WARN deprecated eslint-loader@1.9.0: This loader has been deprecated. Please use eslint-webpack-plugin
2:20:55 AM: npm WARN deprecated extract-text-webpack-plugin@3.0.2: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
2:20:56 AM: npm WARN deprecated html-webpack-plugin@2.29.0: out of support
2:20:57 AM: npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
2:20:58 AM: npm WARN deprecated babel-eslint@7.2.3: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
2:20:59 AM: npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
2:21:02 AM: npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
2:21:02 AM: npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
2:21:06 AM: npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
2:21:06 AM: npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
2:21:09 AM: npm WARN deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
2:21:12 AM: npm WARN deprecated core-js@1.2.7: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
2:21:14 AM: npm WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
2:21:15 AM: npm WARN deprecated material-ui-icons@1.0.0-beta.36: Use @material-ui/icons instead
2:21:22 AM: added 1893 packages, and audited 1895 packages in 47s
2:21:22 AM: 74 packages are looking for funding
2:21:22 AM:   run `npm fund` for details
2:21:22 AM: 52 vulnerabilities (33 low, 5 moderate, 14 high)
2:21:22 AM: To address issues that do not require attention, run:
2:21:22 AM:   npm audit fix
2:21:22 AM: To address all issues (including breaking changes), run:
2:21:22 AM:   npm audit fix --force
2:21:22 AM: Run `npm audit` for details.
2:21:22 AM: NPM modules installed
2:21:23 AM: Started restoring cached go cache
2:21:23 AM: Finished restoring cached go cache
2:21:23 AM: go version go1.16.5 linux/amd64
2:21:23 AM: go version go1.16.5 linux/amd64
2:21:23 AM: Installing missing commands
2:21:23 AM: Verify run directory
2:21:24 AM: ​
2:21:24 AM: ────────────────────────────────────────────────────────────────
2:21:24 AM:   Netlify Build                                                 
2:21:24 AM: ────────────────────────────────────────────────────────────────
2:21:24 AM: ​
2:21:24 AM: ❯ Version
2:21:24 AM:   @netlify/build 18.13.6
2:21:24 AM: ​
2:21:24 AM: ❯ Flags
2:21:24 AM:   baseRelDir: true
2:21:24 AM:   buildId: 615a3ab933a9ce15e27cbebb
2:21:24 AM:   deployId: 615a3ab933a9ce15e27cbebd
2:21:24 AM: ​
2:21:24 AM: ❯ Current directory
2:21:24 AM:   /opt/build/repo
2:21:24 AM: ​
2:21:24 AM: ❯ Config file
2:21:24 AM:   No config file was defined: using default values.
2:21:24 AM: ​
2:21:24 AM: ❯ Context
2:21:24 AM:   production
2:21:24 AM: ​
2:21:24 AM: ────────────────────────────────────────────────────────────────
2:21:24 AM:   1. Build command from Netlify app                             
2:21:24 AM: ────────────────────────────────────────────────────────────────
2:21:24 AM: ​
2:21:24 AM: $ CI= npm run build
2:21:25 AM: > seedingfund@0.1.0 build
2:21:25 AM: > react-scripts build
2:21:26 AM: Creating an optimized production build...
2:21:36 AM: Failed to compile.
2:21:36 AM: 
2:21:36 AM: ./src/pages/404Error.css
2:21:36 AM: Module build failed: BrowserslistError: Unknown browser query `dead`
2:21:36 AM:     at Array.forEach (<anonymous>)
2:21:36 AM: ​
2:21:36 AM: ────────────────────────────────────────────────────────────────
2:21:36 AM:   "build.command" failed                                        
2:21:36 AM: ────────────────────────────────────────────────────────────────
2:21:36 AM: ​
2:21:36 AM:   Error message
2:21:36 AM:   Command failed with exit code 1: CI= npm run build
2:21:36 AM: ​
2:21:36 AM:   Error location
2:21:36 AM:   In Build command from Netlify app:
2:21:36 AM:   CI= npm run build
2:21:36 AM: ​
2:21:36 AM:   Resolved config
2:21:36 AM:   build:
2:21:36 AM:     command: CI= npm run build
2:21:36 AM:     commandOrigin: ui
2:21:36 AM:     publish: /opt/build/repo/build
2:21:36 AM:     publishOrigin: ui
2:21:36 AM: Caching artifacts
2:21:36 AM: Started saving node modules
2:21:36 AM: Finished saving node modules
2:21:36 AM: Started saving build plugins
2:21:36 AM: Finished saving build plugins
2:21:36 AM: Started saving pip cache
2:21:36 AM: Finished saving pip cache
2:21:36 AM: Started saving emacs cask dependencies
2:21:36 AM: Finished saving emacs cask dependencies
2:21:36 AM: Started saving maven dependencies
2:21:36 AM: Finished saving maven dependencies
2:21:36 AM: Started saving boot dependencies
2:21:36 AM: Finished saving boot dependencies
2:21:36 AM: Started saving rust rustup cache
2:21:36 AM: Finished saving rust rustup cache
2:21:36 AM: Started saving go dependencies
2:21:36 AM: Finished saving go dependencies
2:21:39 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:21:39 AM: Creating deploy upload records
2:21:39 AM: Failing build: Failed to build site
2:21:39 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
2:21:39 AM: Finished processing build request in 1m12.325853736s

Here is screenshots of my deploy settings:

Screenshot from 2021-10-04 02-37-27

Any help is much appreciated, thanks for your time :slight_smile:

Hi @SoulsReaper

The issue is stemming from the not dead listing in browserslist config.

The highest version of browserslist listed in your package-lock.json is v2.11.3 which is now deprecated, and based on the npmjs listing does not support not dead (unlike, for example, v4.6.3 which does.)

The solution then is to remove not dead or upgrade your outdated packages to newer versions that offer this support.

Note: I tested building locally removing not dead and while this error is fixed by doing so, other warnings/errors persist due to unused variables.

2 Likes

OMG thank you so much, it was so frustrating to fix this, you are a life saver!

Do you know how can >I update my packages globally on my ubuntu? I am not that experienced with npm yet, I once tried to change sometime and damaged my whole dependency tree :sweat_smile:

1 Like

Start by checking outdated with npm outdated in your project directory.

Also check out npm update.

This is a possibility when upgrading from deprecated/unmaintained packages. Make a backup of your project (e.g. zip archive) prior to updating so you have something to go back to.

1 Like

Thanks for the great tip, I will try it for sure :grin:

1 Like