Encounter Error Code 127 while deploying an ionic react app

My netlify site name: with-love-irene

I would like to deploy this, however, I kept encountering ionic command not found even though I have already run npm i -D @ionic/cli locally in terminal before pushing the project again.

3:16:31 AM: Build ready to start
3:16:33 AM: build-image version: a49edbc55fc722f80f6b85963a5060f8d043a844 (focal)
3:16:33 AM: build-image tag: v4.8.1
3:16:33 AM: buildbot version: f89dd42aa70d76d1da992dc3fa004a4c745208bc
3:16:33 AM: Fetching cached dependencies
3:16:33 AM: Failed to fetch cache, continuing with build
3:16:33 AM: Starting to prepare the repo for build
3:16:33 AM: No cached dependencies found. Cloning fresh repo
3:16:33 AM: git clone https://github.com/ireneliee/with-love-irene-mirror
3:16:34 AM: Preparing Git Reference refs/heads/main
3:16:34 AM: Parsing package.json dependencies
3:16:35 AM: Starting build script
3:16:35 AM: Installing dependencies
3:16:35 AM: Python version set to 2.7
3:16:36 AM: v16.15.1 is already installed.
3:16:36 AM: Now using node v16.15.1 (npm v8.11.0)
3:16:36 AM: Started restoring cached build plugins
3:16:36 AM: Finished restoring cached build plugins
3:16:36 AM: Attempting ruby version 2.7.2, read from environment
3:16:37 AM: Using ruby version 2.7.2
3:16:38 AM: Using PHP version 8.0
3:16:38 AM: Started restoring cached go cache
3:16:38 AM: Finished restoring cached go cache
3:16:38 AM: Installing Go version 1.17 (requested 1.17)
3:16:43 AM: unset GOOS;
3:16:43 AM: unset GOARCH;
3:16:43 AM: export GOROOT=‘/opt/buildhome/.gimme/versions/go1.17.linux.amd64’;
3:16:43 AM: export PATH=“/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}”;
3:16:43 AM: go version >&2;
3:16:43 AM: export GIMME_ENV=“/opt/buildhome/.gimme/env/go1.17.linux.amd64.env”
3:16:43 AM: go version go1.17 linux/amd64
3:16:43 AM: Installing missing commands
3:16:43 AM: Verify run directory
3:16:45 AM: ​
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: Netlify Build
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: ​
3:16:45 AM: ❯ Version
3:16:45 AM: @netlify/build 27.1.5
3:16:45 AM: ​
3:16:45 AM: ❯ Flags
3:16:45 AM: baseRelDir: true
3:16:45 AM: buildId: 62b2190ff0c5b31cee3a3612
3:16:45 AM: deployId: 62b2190ff0c5b31cee3a3614
3:16:45 AM: ​
3:16:45 AM: ❯ Current directory
3:16:45 AM: /opt/build/repo
3:16:45 AM: ​
3:16:45 AM: ❯ Config file
3:16:45 AM: No config file was defined: using default values.
3:16:45 AM: ​
3:16:45 AM: ❯ Context
3:16:45 AM: production
3:16:45 AM: ​
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: 1. Build command from Netlify app
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: ​
3:16:45 AM: $ ionic build --prod
3:16:45 AM: bash: ionic: command not found
3:16:45 AM: ​
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: “build.command” failed
3:16:45 AM: ────────────────────────────────────────────────────────────────
3:16:45 AM: ​
3:16:45 AM: Error message
3:16:45 AM: Command failed with exit code 127: ionic build --prod (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
3:16:45 AM: ​
3:16:45 AM: Error location
3:16:45 AM: In Build command from Netlify app:
3:16:45 AM: ionic build --prod
3:16:45 AM: ​
3:16:46 AM: Creating deploy upload records
3:16:45 AM: Resolved config
3:16:45 AM: build:
3:16:45 AM: command: ionic build --prod
3:16:45 AM: commandOrigin: ui
3:16:45 AM: publish: /opt/build/repo/www
3:16:45 AM: publishOrigin: ui
3:16:47 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
3:16:45 AM: Caching artifacts
3:16:45 AM: Started saving build plugins
3:16:45 AM: Finished saving build plugins
3:16:45 AM: Started saving pip cache
3:16:45 AM: Finished saving pip cache
3:16:45 AM: Started saving emacs cask dependencies
3:16:45 AM: Finished saving emacs cask dependencies
3:16:45 AM: Started saving maven dependencies
3:16:45 AM: Finished saving maven dependencies
3:16:45 AM: Started saving boot dependencies
3:16:45 AM: Finished saving boot dependencies
3:16:45 AM: Started saving rust rustup cache
3:16:45 AM: Finished saving rust rustup cache
3:16:45 AM: Started saving go dependencies
3:16:45 AM: Finished saving go dependencies
3:16:46 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:16:47 AM: Failing build: Failed to build site
3:16:47 AM: Finished processing build request in 14.105474346s

Hiya, sorry you are having trouble with your build.

This Support Guide contains a ton of useful debugging tips that can likely help you solve your problem :slight_smile: Additionally, this Support Guide houses all of our resources for debugging build and deploy issues.

We also recommend trying to search the forums with the build error you encountered - it’s likely your question was already asked by someone else!

If you are still having problems, please provide as much information as you can on what you have already tried, what your build settings are, your package.json, etc. Thanks!