Netlify not building - Command failed with exit code 1: npm run build

Hello kindly help I used the CI= npm run build. Am still getting this error I have also attached a screenshot of my json file.
1:13:52 PM: Build ready to start
1:13:54 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
1:13:54 PM: build-image tag: v3.5.0
1:13:54 PM: buildbot version: daad1c7f6f985f432faa0e1d50982ae7149f9e0a
1:13:54 PM: Fetching cached dependencies
1:13:54 PM: Failed to fetch cache, continuing with build
1:13:54 PM: Starting to prepare the repo for build
1:13:55 PM: No cached dependencies found. Cloning fresh repo
1:13:55 PM: git clone https://github.com/ivy-ajanga/MyPortfolio
1:13:56 PM: Preparing Git Reference refs/heads/main
1:13:58 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: β€˜build’ versus β€˜build/’ in the Netlify UI
1:13:58 PM: Starting build script
1:13:58 PM: Installing dependencies
1:13:58 PM: Python version set to 2.7
1:14:00 PM: v12.18.0 is already installed.
1:14:00 PM: Now using node v12.18.0 (npm v6.14.4)
1:14:01 PM: Started restoring cached build plugins
1:14:01 PM: Finished restoring cached build plugins
1:14:01 PM: Attempting ruby version 2.7.1, read from environment
1:14:02 PM: Using ruby version 2.7.1
1:14:03 PM: Using PHP version 5.6
1:14:03 PM: Started restoring cached node modules
1:14:03 PM: Finished restoring cached node modules
1:14:03 PM: Installing NPM modules using NPM version 6.14.4
1:14:06 PM: npm WARN MyPortfolio@1.0.0 No repository field.
1:14:06 PM: up to date in 2.646s
1:14:06 PM: found 0 vulnerabilities
1:14:06 PM: NPM modules installed
1:14:07 PM: Started restoring cached go cache
1:14:07 PM: Finished restoring cached go cache
1:14:07 PM: go version go1.14.4 linux/amd64
1:14:07 PM: go version go1.14.4 linux/amd64
1:14:07 PM: Installing missing commands
1:14:07 PM: Verify run directory
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: Netlify Build
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: ❯ Version
1:14:09 PM: @netlify/build 5.5.2
1:14:09 PM: ​
1:14:09 PM: ❯ Flags
1:14:09 PM: deployId: 5fc8ba6057cfa0ebb9716e6b
1:14:09 PM: mode: buildbot
1:14:09 PM: ​
1:14:09 PM: ❯ Current directory
1:14:09 PM: /opt/build/repo
1:14:09 PM: ​
1:14:09 PM: ❯ Config file
1:14:09 PM: No config file was defined: using default values.
1:14:09 PM: ​
1:14:09 PM: ❯ Context
1:14:09 PM: production
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: 1. Build command from Netlify app
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: $ CI= npm run build
1:14:09 PM: npm ERR! missing script: build
1:14:09 PM: npm ERR! A complete log of this run can be found in:
1:14:09 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-12-03T10_14_09_428Z-debug.log
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: β€œbuild.command” failed
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: Error message
1:14:09 PM: Command failed with exit code 1: CI= npm run build
1:14:09 PM: ​
1:14:09 PM: Error location
1:14:09 PM: In Build command from Netlify app:
1:14:09 PM: CI= npm run build
1:14:09 PM: ​
1:14:09 PM: Resolved config
1:14:09 PM: build:
1:14:09 PM: command: CI= npm run build
1:14:09 PM: commandOrigin: ui
1:14:09 PM: publish: /opt/build/repo/build
1:14:09 PM: Caching artifacts
1:14:09 PM: Started saving node modules
1:14:09 PM: Finished saving node modules
1:14:09 PM: Started saving build plugins
1:14:09 PM: Finished saving build plugins
1:14:09 PM: Started saving pip cache
1:14:09 PM: Finished saving pip cache
1:14:09 PM: Started saving emacs cask dependencies
1:14:09 PM: Finished saving emacs cask dependencies
1:14:09 PM: Started saving maven dependencies
1:14:09 PM: Finished saving maven dependencies
1:14:09 PM: Started saving boot dependencies
1:14:09 PM: Finished saving boot dependencies
1:14:09 PM: Started saving go dependencies
1:14:09 PM: Finished saving go dependencies
1:14:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:14:12 PM: Failing build: Failed to build site
1:14:12 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
1:14:12 PM: Finished processing build request in 17.979369755s

Hello kindly help I used the CI= npm run build. Am still getting this error I have also attached a screenshot of my json file.
1:13:52 PM: Build ready to start
1:13:54 PM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41
1:13:54 PM: build-image tag: v3.5.0
1:13:54 PM: buildbot version: daad1c7f6f985f432faa0e1d50982ae7149f9e0a
1:13:54 PM: Fetching cached dependencies
1:13:54 PM: Failed to fetch cache, continuing with build
1:13:54 PM: Starting to prepare the repo for build
1:13:55 PM: No cached dependencies found. Cloning fresh repo
1:13:55 PM: git clone https://github.com/ivy-ajanga/MyPortfolio
1:13:56 PM: Preparing Git Reference refs/heads/main
1:13:58 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: β€˜build’ versus β€˜build/’ in the Netlify UI
1:13:58 PM: Starting build script
1:13:58 PM: Installing dependencies
1:13:58 PM: Python version set to 2.7
1:14:00 PM: v12.18.0 is already installed.
1:14:00 PM: Now using node v12.18.0 (npm v6.14.4)
1:14:01 PM: Started restoring cached build plugins
1:14:01 PM: Finished restoring cached build plugins
1:14:01 PM: Attempting ruby version 2.7.1, read from environment
1:14:02 PM: Using ruby version 2.7.1
1:14:03 PM: Using PHP version 5.6
1:14:03 PM: Started restoring cached node modules
1:14:03 PM: Finished restoring cached node modules
1:14:03 PM: Installing NPM modules using NPM version 6.14.4
1:14:06 PM: npm WARN MyPortfolio@1.0.0 No repository field.
1:14:06 PM: up to date in 2.646s
1:14:06 PM: found 0 vulnerabilities
1:14:06 PM: NPM modules installed
1:14:07 PM: Started restoring cached go cache
1:14:07 PM: Finished restoring cached go cache
1:14:07 PM: go version go1.14.4 linux/amd64
1:14:07 PM: go version go1.14.4 linux/amd64
1:14:07 PM: Installing missing commands
1:14:07 PM: Verify run directory
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: Netlify Build
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: ❯ Version
1:14:09 PM: @netlify/build 5.5.2
1:14:09 PM: ​
1:14:09 PM: ❯ Flags
1:14:09 PM: deployId: 5fc8ba6057cfa0ebb9716e6b
1:14:09 PM: mode: buildbot
1:14:09 PM: ​
1:14:09 PM: ❯ Current directory
1:14:09 PM: /opt/build/repo
1:14:09 PM: ​
1:14:09 PM: ❯ Config file
1:14:09 PM: No config file was defined: using default values.
1:14:09 PM: ​
1:14:09 PM: ❯ Context
1:14:09 PM: production
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: 1. Build command from Netlify app
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: $ CI= npm run build
1:14:09 PM: npm ERR! missing script: build
1:14:09 PM: npm ERR! A complete log of this run can be found in:
1:14:09 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-12-03T10_14_09_428Z-debug.log
1:14:09 PM: ​
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: β€œbuild.command” failed
1:14:09 PM: ────────────────────────────────────────────────────────────────
1:14:09 PM: ​
1:14:09 PM: Error message
1:14:09 PM: Command failed with exit code 1: CI= npm run build
1:14:09 PM: ​
1:14:09 PM: Error location
1:14:09 PM: In Build command from Netlify app:
1:14:09 PM: CI= npm run build
1:14:09 PM: ​
1:14:09 PM: Resolved config
1:14:09 PM: build:
1:14:09 PM: command: CI= npm run build
1:14:09 PM: commandOrigin: ui
1:14:09 PM: publish: /opt/build/repo/build
1:14:09 PM: Caching artifacts
1:14:09 PM: Started saving node modules
1:14:09 PM: Finished saving node modules
1:14:09 PM: Started saving build plugins
1:14:09 PM: Finished saving build plugins
1:14:09 PM: Started saving pip cache
1:14:09 PM: Finished saving pip cache
1:14:09 PM: Started saving emacs cask dependencies
1:14:09 PM: Finished saving emacs cask dependencies
1:14:09 PM: Started saving maven dependencies
1:14:09 PM: Finished saving maven dependencies
1:14:09 PM: Started saving boot dependencies
1:14:09 PM: Finished saving boot dependencies
1:14:09 PM: Started saving go dependencies
1:14:09 PM: Finished saving go dependencies
1:14:12 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:14:12 PM: Failing build: Failed to build site
1:14:12 PM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
1:14:12 PM: Finished processing build request in 17.979369755s

Hey @IvyAjanga,
So so sorry for the long delay here! I was able to find your site based on your deploy log, and I took a look at your settings in the site dashboard here: Netlify App

It looks like you have the correct build command there. From there, our buildbots run the command listed (CI= npm run build), which basically says β€œrun whatever is listed as the β€œbuild” script in the package.json”, but then get snagged by your package.json, which does not have a build script:
https://github.com/ivy-ajanga/MyPortfolio/blob/main/package.json#L9

You have β€œtest” but you will need a line that says β€œbuild”, so:

  "scripts": {
    "build": "..." <--- you need something in here
    "test": "echo \"Error: no test specified\" && exit 1"
  },

I couldn’t tell what framework you’re using to build, but the framework docs should tell you what that command needs to be. Let us know if there are any other questions and we’ll be happy to help!

Thank you! This was driving me crazy! :pray:

13 posts were split to a new topic: Jekyll site won’t build: Error: No such file or directory @ rb_sysopen