Build script returned non-zero exit code: 2, bash: remix: command not found

Hello. I’m facing an issue when deploying a React project. Here’s the log:

10:37:21 AM: Waiting for other deploys from your team to complete. Check the queue: https://app.netlify.com/teams/mjeppo/builds
10:38:01 AM: build-image version: c3449036692ceba113a2b71302d561bccc8b6156 (focal)
10:38:01 AM: buildbot version: 6e5dfadf0eec598d7c9db5c1e005bfa46b6682c0
10:38:01 AM: Fetching cached dependencies
10:38:01 AM: Failed to fetch cache, continuing with build
10:38:01 AM: Starting to prepare the repo for build
10:38:01 AM: No cached dependencies found. Cloning fresh repo
10:38:01 AM: git clone --filter=blob:none https://github.com/mjeppo/pokedex
10:38:02 AM: Preparing Git Reference refs/heads/main
10:38:04 AM: Starting to install dependencies
10:38:05 AM: mise python@3.13.1   install
10:38:05 AM: mise python@3.13.1   download cpython-3.13.1+20241219-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
10:38:05 AM: mise python@3.13.1   extract cpython-3.13.1+20241219-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz
10:38:06 AM: mise python@3.13.1   python --version
10:38:06 AM: mise python@3.13.1   Python 3.13.1
10:38:06 AM: mise python@3.13.1 ✓ installed
10:38:06 AM: Python version set to 3.13
10:38:07 AM: Collecting pipenv
10:38:07 AM:   Downloading pipenv-2024.4.0-py3-none-any.whl.metadata (19 kB)
10:38:07 AM: Collecting certifi (from pipenv)
10:38:07 AM:   Downloading certifi-2024.12.14-py3-none-any.whl.metadata (2.3 kB)
10:38:07 AM: Collecting packaging>=22 (from pipenv)
10:38:07 AM:   Downloading packaging-24.2-py3-none-any.whl.metadata (3.2 kB)
10:38:07 AM: Collecting setuptools>=67 (from pipenv)
10:38:07 AM:   Downloading setuptools-75.6.0-py3-none-any.whl.metadata (6.7 kB)
10:38:07 AM: Collecting virtualenv>=20.24.2 (from pipenv)
10:38:07 AM:   Downloading virtualenv-20.28.1-py3-none-any.whl.metadata (4.5 kB)
10:38:07 AM: Collecting distlib<1,>=0.3.7 (from virtualenv>=20.24.2->pipenv)
10:38:07 AM:   Downloading distlib-0.3.9-py2.py3-none-any.whl.metadata (5.2 kB)
10:38:07 AM: Collecting filelock<4,>=3.12.2 (from virtualenv>=20.24.2->pipenv)
10:38:07 AM:   Downloading filelock-3.16.1-py3-none-any.whl.metadata (2.9 kB)
10:38:07 AM: Collecting platformdirs<5,>=3.9.1 (from virtualenv>=20.24.2->pipenv)
10:38:07 AM:   Downloading platformdirs-4.3.6-py3-none-any.whl.metadata (11 kB)
10:38:07 AM: Downloading pipenv-2024.4.0-py3-none-any.whl (3.0 MB)
10:38:08 AM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.0/3.0 MB 59.5 MB/s eta 0:00:00
10:38:08 AM: Downloading packaging-24.2-py3-none-any.whl (65 kB)
10:38:08 AM: Downloading setuptools-75.6.0-py3-none-any.whl (1.2 MB)
10:38:08 AM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 68.8 MB/s eta 0:00:00
10:38:08 AM: Downloading virtualenv-20.28.1-py3-none-any.whl (4.3 MB)
10:38:08 AM:    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 148.4 MB/s eta 0:00:00
10:38:08 AM: Downloading certifi-2024.12.14-py3-none-any.whl (164 kB)
10:38:08 AM: Downloading distlib-0.3.9-py2.py3-none-any.whl (468 kB)
10:38:08 AM: Downloading filelock-3.16.1-py3-none-any.whl (16 kB)
10:38:08 AM: Downloading platformdirs-4.3.6-py3-none-any.whl (18 kB)
10:38:08 AM: Installing collected packages: distlib, setuptools, platformdirs, packaging, filelock, certifi, virtualenv, pipenv
10:38:10 AM: Successfully installed certifi-2024.12.14 distlib-0.3.9 filelock-3.16.1 packaging-24.2 pipenv-2024.4.0 platformdirs-4.3.6 setuptools-75.6.0 virtualenv-20.28.1
10:38:10 AM: Attempting Ruby version 2.7.2, read from environment
10:38:11 AM: Using Ruby version 2.7.2
10:38:12 AM: Started restoring cached go cache
10:38:12 AM: Finished restoring cached go cache
10:38:13 AM: go version go1.19.13 linux/amd64
10:38:14 AM: Using PHP version 8.0
10:38:15 AM: v18.20.5 is already installed.
10:38:16 AM: Now using node v18.20.5 (npm v10.8.2)
10:38:16 AM: Enabling Node.js Corepack
10:38:16 AM: Started restoring cached build plugins
10:38:16 AM: Finished restoring cached build plugins
10:38:16 AM: Started restoring cached corepack dependencies
10:38:16 AM: Finished restoring cached corepack dependencies
10:38:16 AM: No npm workspaces detected
10:38:16 AM: Started restoring cached node modules
10:38:16 AM: Finished restoring cached node modules
10:38:16 AM: Installing npm packages using npm version 10.8.2
10:38:19 AM: added 261 packages, and audited 262 packages in 3s
10:38:19 AM: 107 packages are looking for funding
10:38:19 AM:   run `npm fund` for details
10:38:19 AM: found 0 vulnerabilities
10:38:19 AM: npm packages installed
10:38:19 AM: Successfully installed dependencies
10:38:19 AM: Starting build script
10:38:20 AM: Detected 2 framework(s)
10:38:20 AM: "remix" at version "2.15.2"
10:38:20 AM: "vite" at version "6.0.7"
10:38:20 AM: Section completed: initializing
10:38:22 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:38:22 AM: ​
10:38:22 AM: Netlify Build                                                 
10:38:22 AM: ────────────────────────────────────────────────────────────────
10:38:22 AM: ​
10:38:22 AM: ❯ Version
10:38:22 AM:   @netlify/build 29.58.1
10:38:22 AM: ​
10:38:22 AM: ❯ Flags
10:38:22 AM:   accountId: 65cbbf6ece3c3411180227ac
10:38:22 AM:   baseRelDir: true
10:38:22 AM:   buildId: 677a52d1053c2b2594d66f38
10:38:22 AM:   deployId: 677a52d1053c2b2594d66f3a
10:38:22 AM: ​
10:38:22 AM: ❯ Current directory
10:38:22 AM:   /opt/build/repo
10:38:22 AM: ​
10:38:22 AM: ❯ Config file
10:38:22 AM:   No config file was defined: using default values.
10:38:22 AM: ​
10:38:22 AM: ❯ Context
10:38:22 AM:   production
10:38:22 AM: ​
10:38:22 AM: Build command from Netlify app                                
10:38:22 AM: ────────────────────────────────────────────────────────────────
10:38:22 AM: ​
10:38:22 AM: $ remix vite:build
10:38:22 AM: bash: remix: command not found
10:38:22 AM: ​
10:38:22 AM: "build.command" failed                                        
10:38:22 AM: ────────────────────────────────────────────────────────────────
10:38:22 AM: ​
10:38:22 AM:   Error message
10:38:22 AM:   Command failed with exit code 127: remix vite:build (https://ntl.fyi/exit-code-127)
10:38:22 AM: ​
10:38:22 AM:   Error location
10:38:22 AM:   In Build command from Netlify app:
10:38:22 AM:   remix vite:build
10:38:22 AM: ​
10:38:22 AM:   Resolved config
10:38:22 AM:   build:
10:38:22 AM:     command: remix vite:build
10:38:22 AM:     commandOrigin: ui
10:38:22 AM:     publish: /opt/build/repo/dist/client
10:38:22 AM:     publishOrigin: ui
10:38:22 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:38:22 AM: Failing build: Failed to build site
10:38:23 AM: Finished processing build request in 21.851s

I have tried different possible solutions, all to no availe. Couls someone help me please? Tia

Try using npm run build as the command.

Thank you hrishikesh. How can I do that? Running that command in VS code doesn’t change anything in my repository, so there are no changes to commit to Git…

Hi @mjeppo,

You should be able to do that here:

by changing the build command to npm run build.

You can read more here in Netlify’s docs: