"Command failed with exit code 127: npm run build" previous solutions not working

Hello!

I am really struggling to find the error with this deployment. My site is named: lovely-gingersnap-a6173e and I am trying to deploy a react app to netlify.

I’ve heard all about CI= npm run build being a solution to common problems and setting CI to false in the environment variables, but none of that has worked.

Here is the error:

1:14:02 PM: build-image version: c0621868af5001023389eeaa9dbfbbaf313f67e2 (focal)
1:14:02 PM: buildbot version: c0621868af5001023389eeaa9dbfbbaf313f67e2
1:14:02 PM: Fetching cached dependencies
1:14:02 PM: Failed to fetch cache, continuing with build
1:14:02 PM: Starting to prepare the repo for build
1:14:02 PM: No cached dependencies found. Cloning fresh repo
1:14:02 PM: git clone --filter=blob:none https://github.com/petermazzocco/tim-website-master
1:14:03 PM: Preparing Git Reference refs/heads/master
1:14:04 PM: Parsing package.json dependencies
1:14:05 PM: Starting to install dependencies
1:14:05 PM: Using PHP version 8.0
1:14:06 PM: Started restoring cached go cache
1:14:06 PM: Finished restoring cached go cache
1:14:06 PM: Installing Go version 1.19.5 (requested 1.19.5)
1:14:11 PM: go version go1.19.5 linux/amd64
1:14:12 PM: v16.19.1 is already installed.
1:14:12 PM: Now using node v16.19.1 (npm v8.19.3)
1:14:12 PM: Enabling Node.js Corepack
1:14:12 PM: Started restoring cached build plugins
1:14:12 PM: Finished restoring cached build plugins
1:14:12 PM: Started restoring cached corepack dependencies
1:14:12 PM: Finished restoring cached corepack dependencies
1:14:12 PM: No npm workspaces detected
1:14:12 PM: Started restoring cached node modules
1:14:12 PM: Finished restoring cached node modules
1:14:13 PM: Installing npm packages using npm version 8.19.3
1:14:18 PM: npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
1:14:18 PM: npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
1:14:19 PM: npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
1:14:19 PM: npm WARN deprecated sourcemap-codec@1.4.8: Please use @jridgewell/sourcemap-codec instead
1:14:19 PM: npm WARN deprecated rollup-plugin-terser@7.0.2: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-terser
1:14:20 PM: npm WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
1:14:21 PM: npm WARN deprecated svgo@1.3.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
1:14:25 PM: npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
1:14:25 PM: npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
1:14:29 PM: added 2062 packages, and audited 2063 packages in 16s
1:14:29 PM: 240 packages are looking for funding
1:14:29 PM:   run `npm fund` for details
1:14:29 PM: 6 high severity vulnerabilities
1:14:29 PM: To address all issues (including breaking changes), run:
1:14:29 PM:   npm audit fix --force
1:14:29 PM: Run `npm audit` for details.
1:14:29 PM: npm packages installed
1:14:30 PM: Python version set to 3.8
1:14:30 PM: Attempting Ruby version 2.7.2, read from environment
1:14:30 PM: Using Ruby version 2.7.2
1:14:31 PM: Install dependencies script success
1:14:31 PM: Starting build script
1:14:31 PM: Using stage install dependencies
1:14:31 PM: Detected 1 framework(s)
1:14:31 PM: "create-react-app" at version "5.0.1"
1:14:31 PM: Section completed: initializing
1:14:33 PM: ​
1:14:33 PM:   Netlify Build                                                 
1:14:33 PM: ────────────────────────────────────────────────────────────────
1:14:33 PM: ​
1:14:33 PM: ❯ Version
1:14:33 PM:   @netlify/build 29.5.8
1:14:33 PM: ​
1:14:33 PM: ❯ Flags
1:14:33 PM:   baseRelDir: true
1:14:33 PM:   buildId: 63f534180fbda400831dcd5a
1:14:33 PM:   deployId: 63f534180fbda400831dcd5c
1:14:33 PM: ​
1:14:33 PM: ❯ Current directory
1:14:33 PM:   /opt/build/repo
1:14:33 PM: ​
1:14:33 PM: ❯ Config file
1:14:33 PM:   No config file was defined: using default values.
1:14:33 PM: ​
1:14:33 PM: ❯ Context
1:14:33 PM:   production
1:14:33 PM: ​
1:14:33 PM:   1. Build command from Netlify app                             
1:14:33 PM: ────────────────────────────────────────────────────────────────
1:14:33 PM: ​
1:14:33 PM: $ npm run build
1:14:33 PM: > tim-website@0.1.0 build
1:14:33 PM: > react-stripts build
1:14:33 PM: sh: 1: react-stripts: not found
1:14:33 PM: ​
1:14:33 PM:   "build.command" failed                                        
1:14:33 PM: ────────────────────────────────────────────────────────────────
1:14:33 PM: ​
1:14:33 PM:   Error message
1:14:33 PM:   Command failed with exit code 127: npm run build (https://ntl.fyi/exit-code-127)
1:14:33 PM: ​
1:14:33 PM:   Error location
1:14:34 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:14:33 PM:   In Build command from Netlify app:
1:14:33 PM:   npm run build
1:14:33 PM: ​
1:14:33 PM:   Resolved config
1:14:33 PM:   build:
1:14:33 PM:     command: npm run build
1:14:33 PM:     commandOrigin: ui
1:14:33 PM:     environment:
1:14:33 PM:       - CI
1:14:33 PM:     publish: /opt/build/repo/build
1:14:33 PM:     publishOrigin: ui
1:14:33 PM: Caching artifacts
1:14:33 PM: Started saving node modules
1:14:33 PM: Finished saving node modules
1:14:33 PM: Started saving build plugins
1:14:33 PM: Finished saving build plugins
1:14:33 PM: Started saving corepack cache
1:14:33 PM: Finished saving corepack cache
1:14:33 PM: Started saving pip cache
1:14:33 PM: Finished saving pip cache
1:14:33 PM: Started saving emacs cask dependencies
1:14:33 PM: Finished saving emacs cask dependencies
1:14:33 PM: Started saving maven dependencies
1:14:33 PM: Finished saving maven dependencies
1:14:33 PM: Started saving boot dependencies
1:14:33 PM: Finished saving boot dependencies
1:14:33 PM: Started saving rust rustup cache
1:14:33 PM: Finished saving rust rustup cache
1:14:33 PM: Started saving go dependencies
1:14:33 PM: Finished saving go dependencies
1:14:34 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:14:34 PM: Failing build: Failed to build site
1:14:34 PM: Finished processing build request in 32.21s

Here is what I’ve done so far:

  • Tried a normal commit with no CI changes
  • Set CI= npm run build
  • Set CI= npm run build and created an environment for CI to be false
  • Set an environment for CI to be false

I truly don’t understand the issue and I could use a little help in the right direction!

Here are my scripts in my package.json file:

  "scripts": {
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "dev": "react-scripts dev",
    "build": "react-stripts build",
    "start": "react-scripts start",
    "lint": "react-scripts lint"
  }

@OhItsPM Setting CI=false isn’t a magic cure for all issues, all it does is disable the default handling where a warning is treated as an error and thus causes a build to fail.

If your build has a legitimate error then it will still fail, as having a build succeed that contains errors wouldn’t make a lot of sense.

Netlify is running npm run build

1:14:33 PM: $ npm run build

As per your package.json that script contains the command…

“build”: “react-stripts build”,

You can see that Netlify is running that command…

1:14:33 PM: > react-stripts build

The build cannot find react-scripts

1:14:33 PM: sh: 1: react-stripts: not found

Have you investigated why it cannot find react-scripts?
Do you have it as a dependency?

Yes i do have react-scripts as a dependency

    "react-scripts": "5.0.1",

@OhItsPM I just noticed your typo myself, while you have react-scripts installed, you don’t have react-stripts installed.

Notice that you have a t instead of a c.

Oh my goodness how embarrassing…

Thank you so much haha

Nice catch @nathanmartin! @OhItsPM I hope this helped solved your problem (: