Unable to deploy react app due to build error

Hi team,

I am trying to deploy my full-stack react app, however I am unable to fix the error I am encountering.

Please see the deploy log and relevant details below:

Site name/ domain : [splendid-tapioca-9dae95] (Netlify App)

github source code: https://github.com/Shakadeliks/figaro-fullstack-e-commerce-store

Deploy Log:

6:04:10 PM: Build ready to start
6:04:13 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
6:04:13 PM: build-image tag: v4.8.0
6:04:13 PM: buildbot version: 29e546ddee264a16af472b38ccba15b350150213
6:04:13 PM: Fetching cached dependencies
6:04:13 PM: Failed to fetch cache, continuing with build
6:04:13 PM: Starting to prepare the repo for build
6:04:13 PM: No cached dependencies found. Cloning fresh repo
6:04:13 PM: git clone GitHub - Shakadeliks/figaro-fullstack-e-commerce-store
6:04:15 PM: Preparing Git Reference refs/heads/main
6:04:16 PM: Parsing package.json dependencies
6:04:17 PM: Starting build script
6:04:18 PM: Installing dependencies
6:04:18 PM: Python version set to 2.7
6:04:19 PM: Downloading and installing node v16.15.0…
6:04:19 PM: Downloading https://nodejs.org/dist/v16.15.0/node-v16.15.0-linux-x64.tar.xz…
6:04:19 PM: Computing checksum with sha256sum
6:04:20 PM: Checksums matched!
6:04:23 PM: Now using node v16.15.0 (npm v8.5.5)
6:04:23 PM: Started restoring cached build plugins
6:04:23 PM: Finished restoring cached build plugins
6:04:23 PM: Attempting ruby version 2.7.2, read from environment
6:04:25 PM: Using ruby version 2.7.2
6:04:25 PM: Using PHP version 8.0
6:04:25 PM: Started restoring cached go cache
6:04:25 PM: Finished restoring cached go cache
6:04:26 PM: go version go1.16.5 linux/amd64
6:04:26 PM: go version go1.16.5 linux/amd64
6:04:26 PM: Installing missing commands
6:04:26 PM: Verify run directory
6:04:28 PM: ​
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: Netlify Build
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: ​
6:04:28 PM: ❯ Version
6:04:28 PM: @netlify/build 27.1.1
6:04:28 PM: ​
6:04:28 PM: ❯ Flags
6:04:28 PM: baseRelDir: true
6:04:28 PM: buildId: 627fd2faf1045a0a75fc8643
6:04:28 PM: deployId: 627fd2faf1045a0a75fc8645
6:04:28 PM: ​
6:04:28 PM: ❯ Current directory
6:04:28 PM: /opt/build/repo
6:04:28 PM: ​
6:04:28 PM: ❯ Config file
6:04:28 PM: No config file was defined: using default values.
6:04:28 PM: ​
6:04:28 PM: ❯ Context
6:04:28 PM: production
6:04:28 PM: ​
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: 1. Build command from Netlify app
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: ​
6:04:28 PM: $ npm run build
6:04:28 PM: npm ERR! code ENOENT
6:04:28 PM: npm ERR! syscall open
6:04:28 PM: npm ERR! path /opt/build/repo/package.json
6:04:28 PM: npm ERR! errno -2
6:04:28 PM: npm ERR! enoent ENOENT: no such file or directory, open β€˜/opt/build/repo/package.json’
6:04:28 PM: npm ERR! enoent This is related to npm not being able to find a file.
6:04:28 PM: npm ERR! enoent
6:04:28 PM: npm ERR! A complete log of this run can be found in:
6:04:28 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-05-14T16_04_28_418Z-debug-0.log
6:04:28 PM: ​
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: β€œbuild.command” failed
6:04:28 PM: ────────────────────────────────────────────────────────────────
6:04:28 PM: ​
6:04:28 PM: Error message
6:04:28 PM: Command failed with exit code 254: npm run build (Search results for '"non-zero exit code: 254"' - Netlify Support Forums)
6:04:28 PM: ​
6:04:28 PM: Error location
6:04:28 PM: In Build command from Netlify app:
6:04:28 PM: npm run build
6:04:28 PM: ​
6:04:28 PM: Resolved config
6:04:28 PM: build:
6:04:28 PM: command: npm run build
6:04:28 PM: commandOrigin: ui
6:04:28 PM: publish: /opt/build/repo/build
6:04:28 PM: publishOrigin: ui
6:04:29 PM: Caching artifacts
6:04:29 PM: Started saving build plugins
6:04:29 PM: Finished saving build plugins
6:04:29 PM: Started saving pip cache
6:04:29 PM: Finished saving pip cache
6:04:29 PM: Started saving emacs cask dependencies
6:04:29 PM: Finished saving emacs cask dependencies
6:04:29 PM: Started saving maven dependencies
6:04:29 PM: Finished saving maven dependencies
6:04:29 PM: Started saving boot dependencies
6:04:29 PM: Finished saving boot dependencies
6:04:29 PM: Started saving rust rustup cache
6:04:29 PM: Finished saving rust rustup cache
6:04:29 PM: Started saving go dependencies
6:04:29 PM: Finished saving go dependencies
6:04:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:04:31 PM: Creating deploy upload records
6:04:31 PM: Failing build: Failed to build site
6:04:31 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
6:04:31 PM: Finished processing build request in 18.731426125s

Build Settings:

Please advise if further info is needed.

Any assistance with this is much appreciated.

You probably need to change the base directory here: Netlify App

to: figaro-front-end

Thank you for the response! I managed to the deploy the site thanks to your help.

1 Like