Home
Support Forums

Error: Command failed with exit code 1: CI= npm run build. npm ERR! Missing script: "build"Even though I have a build script in package.json

Site Name: https://netruh.netlify.app/

My Build Log:

12:31:36 AM: Build ready to start
12:31:38 AM: build-image version: 081db65c3e4ce8423fedb40e7689a87de6f84667
12:31:38 AM: build-image tag: v4.3.1
12:31:38 AM: buildbot version: cd472ed83588da774a80e84962d870b803c1ae34
12:31:38 AM: Building without cache
12:31:38 AM: Starting to prepare the repo for build
12:31:38 AM: No cached dependencies found. Cloning fresh repo
12:31:38 AM: git clone https://github.com/AdityaNair102001/Video-Lib-React
12:31:39 AM: Preparing Git Reference refs/heads/main
12:31:39 AM: Parsing package.json dependencies
12:31:40 AM: Starting build script
12:31:40 AM: Installing dependencies
12:31:40 AM: Python version set to 2.7
12:31:41 AM: v16.9.1 is already installed.
12:31:41 AM: Now using node v16.9.1 (npm v7.21.1)
12:31:41 AM: Started restoring cached build plugins
12:31:41 AM: Finished restoring cached build plugins
12:31:41 AM: Attempting ruby version 2.7.2, read from environment
12:31:43 AM: Using ruby version 2.7.2
12:31:43 AM: Using PHP version 8.0
12:31:43 AM: Started restoring cached go cache
12:31:43 AM: Finished restoring cached go cache
12:31:43 AM: go version go1.16.5 linux/amd64
12:31:43 AM: go version go1.16.5 linux/amd64
12:31:43 AM: Installing missing commands
12:31:43 AM: Verify run directory
12:31:45 AM: ​
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM:   Netlify Build                                                 
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM: ​
12:31:45 AM: ❯ Version
12:31:45 AM:   @netlify/build 18.10.0
12:31:45 AM: ​
12:31:45 AM: ❯ Flags
12:31:45 AM:   baseRelDir: true
12:31:45 AM:   buildId: 614394900f59fa00be699b45
12:31:45 AM:   deployId: 614394900f59fa00be699b47
12:31:45 AM: ​
12:31:45 AM: ❯ Current directory
12:31:45 AM:   /opt/build/repo
12:31:45 AM: ​
12:31:45 AM: ❯ Config file
12:31:45 AM:   No config file was defined: using default values.
12:31:45 AM: ​
12:31:45 AM: ❯ Context
12:31:45 AM:   production
12:31:45 AM: ​
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM:   1. Build command from Netlify app                             
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM: ​
12:31:45 AM: $ CI= npm run build
12:31:45 AM: npm ERR! Missing script: "build"
12:31:45 AM: npm ERR!
12:31:45 AM: npm ERR! To see a list of scripts, run:
12:31:45 AM: npm ERR!   npm run
12:31:45 AM: npm ERR! A complete log of this run can be found in:
12:31:45 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-16T19_01_45_750Z-debug.log
12:31:45 AM: ​
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM:   "build.command" failed                                        
12:31:45 AM: ────────────────────────────────────────────────────────────────
12:31:45 AM: ​
12:31:45 AM:   Error message
12:31:45 AM:   Command failed with exit code 1: CI= npm run build
12:31:45 AM: ​
12:31:45 AM:   Error location
12:31:45 AM:   In Build command from Netlify app:
12:31:45 AM:   CI= npm run build
12:31:45 AM: ​
12:31:45 AM:   Resolved config
12:31:45 AM:   build:
12:31:45 AM:     command: CI= npm run build
12:31:45 AM:     commandOrigin: ui
12:31:45 AM:     publish: /opt/build/repo/build
12:31:45 AM:     publishOrigin: ui
12:31:46 AM: Caching artifacts
12:31:46 AM: Started saving build plugins
12:31:46 AM: Finished saving build plugins
12:31:46 AM: Started saving pip cache
12:31:46 AM: Finished saving pip cache
12:31:46 AM: Started saving emacs cask dependencies
12:31:46 AM: Finished saving emacs cask dependencies
12:31:46 AM: Started saving maven dependencies
12:31:46 AM: Finished saving maven dependencies
12:31:46 AM: Started saving boot dependencies
12:31:46 AM: Finished saving boot dependencies
12:31:46 AM: Started saving rust rustup cache
12:31:46 AM: Finished saving rust rustup cache
12:31:46 AM: Started saving go dependencies
12:31:46 AM: Finished saving go dependencies
12:31:48 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:31:48 AM: Creating deploy upload records
12:31:48 AM: Failing build: Failed to build site
12:31:48 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
12:31:48 AM: Finished processing build request in 10.130468116s

I have a build script in my package.json file:

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

This is my domain settings:

Hi @AdityaNair102001

The issue here is not a missing build script but rather the build bots can’t find it because it is in another directory other than the root.

You could

  1. Move everything in the video-lib directory in the root of your GitHub project
    OR
  2. Set Base directory in the build settings to video-lib.