Build.command failed, "Command failed with exit code 254: CI= npm run build"

netlify site name. stoic-jennings-71c2f4.netlify.app

I initially had put npm run build, didn’t work and I saw that using CI= npm run build would work, but that wasn’t the case with me, I even put CI (and value = false) on the environment variables but still wouldn’t work.

11:21:02 AM: Build ready to start
11:21:05 AM: build-image version: 73def8bb10593b9b818f44989a75ea508018ccb7 (focal)
11:21:05 AM: build-image tag: v4.5.2
11:21:05 AM: buildbot version: 8cd320132979d1a1a502e85e77b47b97cc7d659f
11:21:05 AM: Building without cache
11:21:05 AM: Starting to prepare the repo for build
11:21:05 AM: No cached dependencies found. Cloning fresh repo
11:21:05 AM: git clone GitHub - OmarNassar01/TheRealDealv1
11:21:06 AM: Preparing Git Reference refs/heads/main
11:21:06 AM: Parsing package.json dependencies
11:21:07 AM: Starting build script
11:21:07 AM: Installing dependencies
11:21:07 AM: Python version set to 2.7
11:21:08 AM: Downloading and installing node v16.13.2…
11:21:08 AM: Downloading https://nodejs.org/dist/v16.13.2/node-v16.13.2-linux-x64.tar.xz
11:21:08 AM: Computing checksum with sha256sum
11:21:08 AM: Checksums matched!
11:21:12 AM: Now using node v16.13.2 (npm v8.1.2)
11:21:12 AM: Started restoring cached build plugins
11:21:12 AM: Finished restoring cached build plugins
11:21:12 AM: Attempting ruby version 2.7.2, read from environment
11:21:13 AM: Using ruby version 2.7.2
11:21:14 AM: Using PHP version 8.0
11:21:14 AM: Started restoring cached go cache
11:21:14 AM: Finished restoring cached go cache
11:21:14 AM: go version go1.16.5 linux/amd64
11:21:14 AM: go version go1.16.5 linux/amd64
11:21:14 AM: Installing missing commands
11:21:14 AM: Verify run directory
11:21:15 AM: ​
11:21:15 AM: ────────────────────────────────────────────────────────────────
11:21:15 AM: Netlify Build
11:21:15 AM: ────────────────────────────────────────────────────────────────
11:21:15 AM: ​
11:21:15 AM: ❯ Version
11:21:15 AM: @netlify/build 26.2.0
11:21:15 AM: ​
11:21:15 AM: ❯ Flags
11:21:15 AM: baseRelDir: true
11:21:15 AM: buildId: 61e9378ea29d0fefdf1942ee
11:21:15 AM: deployId: 61e9378ea29d0fefdf1942f0
11:21:15 AM: ​
11:21:15 AM: ❯ Current directory
11:21:15 AM: /opt/build/repo
11:21:15 AM: ​
11:21:15 AM: ❯ Config file
11:21:15 AM: No config file was defined: using default values.
11:21:15 AM: ​
11:21:15 AM: ❯ Context
11:21:15 AM: production
11:21:15 AM: ​
11:21:15 AM: ────────────────────────────────────────────────────────────────
11:21:15 AM: 1. Build command from Netlify app
11:21:15 AM: ────────────────────────────────────────────────────────────────
11:21:15 AM: ​
11:21:15 AM: $ CI= npm run build
11:21:16 AM: npm ERR! code ENOENT
11:21:16 AM: npm ERR! syscall open
11:21:16 AM: npm ERR! path /opt/build/repo/package.json
11:21:16 AM: npm ERR! errno -2
11:21:16 AM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
11:21:16 AM: npm ERR! enoent This is related to npm not being able to find a file.
11:21:16 AM: npm ERR! enoent
11:21:16 AM: npm ERR! A complete log of this run can be found in:
11:21:16 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-01-20T10_21_16_444Z-debug.log
11:21:16 AM: ​
11:21:16 AM: ────────────────────────────────────────────────────────────────
11:21:16 AM: “build.command” failed
11:21:16 AM: ────────────────────────────────────────────────────────────────
11:21:16 AM: ​
11:21:16 AM: Error message
11:21:16 AM: Command failed with exit code 254: CI= npm run build
11:21:16 AM: ​
11:21:16 AM: Error location
11:21:16 AM: In Build command from Netlify app:
11:21:16 AM: CI= npm run build
11:21:16 AM: ​
11:21:16 AM: Resolved config
11:21:16 AM: build:
11:21:16 AM: command: CI= npm run build
11:21:16 AM: commandOrigin: ui
11:21:16 AM: environment:
11:21:16 AM: - CI
11:21:16 AM: publish: /opt/build/repo/build
11:21:16 AM: publishOrigin: ui
11:21:16 AM: Caching artifacts
11:21:16 AM: Started saving build plugins
11:21:16 AM: Finished saving build plugins
11:21:16 AM: Started saving pip cache
11:21:16 AM: Finished saving pip cache
11:21:16 AM: Started saving emacs cask dependencies
11:21:16 AM: Finished saving emacs cask dependencies
11:21:16 AM: Started saving maven dependencies
11:21:16 AM: Finished saving maven dependencies
11:21:16 AM: Started saving boot dependencies
11:21:17 AM: Finished saving boot dependencies
11:21:17 AM: Started saving rust rustup cache
11:21:17 AM: Finished saving rust rustup cache
11:21:17 AM: Started saving go dependencies
11:21:17 AM: Finished saving go dependencies
11:21:19 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:21:19 AM: Creating deploy upload records
11:21:19 AM: Failing build: Failed to build site
11:21:19 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
11:21:19 AM: Finished processing build request in 14.910744415s

The better the post - the faster the answer.

Hi @Godeltrabuco

You need to set the base directory to nft-minting-app-main as per Build from a subdirectory or monorepo documentation (because the code you wish to deploy is in the directory nft-minting-app-main inside the repository.) The publish directory accordingly needs setting to nft-minting-app-main/build as build is the location CRA builds to.

CI= npm run build is only necessary if you as wishing to set CI to false (which ignores warnings. ) For most builds npm run build works.

Thank you so much, really dumb of me not thinking of that… it’s been a long time since i developed something hahah, it works now!!!