Home
Support Forums

Command failed with exit code 254: CI= npm run build

I am not being able to deploy my react app, and getting the below error:
Here is the link to my repo: GitHub - fnumilat/myportfolio: Welcome to my Portfolio's repository.
And here is my command:

7:26:36 AM: Build ready to start
7:26:37 AM: build-image version: 53b83b6bede2920f236b25b6f5a95334320dc849
7:26:37 AM: build-image tag: v3.6.0
7:26:37 AM: buildbot version: 8ae026ef4905d9174e416775c6b64aa19950569b
7:26:37 AM: Building without cache
7:26:37 AM: Starting to prepare the repo for build
7:26:38 AM: No cached dependencies found. Cloning fresh repo
7:26:38 AM: git clone GitHub - fnumilat/myportfolio: Welcome to my Portfolio's repository.
7:26:38 AM: Preparing Git Reference refs/heads/main
7:26:40 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘my-portfolio/build’ versus ‘my-portfolio/build/’ in the Netlify UI
7:26:40 AM: Starting build script
7:26:40 AM: Installing dependencies
7:26:40 AM: Python version set to 2.7
7:26:41 AM: v12.18.0 is already installed.
7:26:41 AM: Now using node v12.18.0 (npm v6.14.4)
7:26:42 AM: Started restoring cached build plugins
7:26:42 AM: Finished restoring cached build plugins
7:26:42 AM: Attempting ruby version 2.7.1, read from environment
7:26:43 AM: Using ruby version 2.7.1
7:26:43 AM: Using PHP version 5.6
7:26:43 AM: Started restoring cached go cache
7:26:43 AM: Finished restoring cached go cache
7:26:43 AM: go version go1.14.4 linux/amd64
7:26:43 AM: go version go1.14.4 linux/amd64
7:26:43 AM: Installing missing commands
7:26:43 AM: Verify run directory
7:26:45 AM: ​
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: Netlify Build
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: ​
7:26:45 AM: ❯ Version
7:26:45 AM: @netlify/build 8.0.0
7:26:45 AM: ​
7:26:45 AM: ❯ Flags
7:26:45 AM: deployId: 5fe5e88c605fe1a317a299c3
7:26:45 AM: mode: buildbot
7:26:45 AM: ​
7:26:45 AM: ❯ Current directory
7:26:45 AM: /opt/build/repo
7:26:45 AM: ​
7:26:45 AM: ❯ Config file
7:26:45 AM: No config file was defined: using default values.
7:26:45 AM: ​
7:26:45 AM: ❯ Context
7:26:45 AM: production
7:26:45 AM: ​
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: 1. Build command from Netlify app
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: ​
7:26:45 AM: $ CI= npm run build
7:26:45 AM: npm ERR! code ENOENT
7:26:45 AM: npm ERR! syscall open
7:26:45 AM: npm ERR! path /opt/build/repo/package.json
7:26:45 AM: npm ERR! errno -2
7:26:45 AM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
7:26:45 AM: npm ERR! enoent This is related to npm not being able to find a file.
7:26:45 AM: npm ERR! enoent
7:26:45 AM: npm ERR! A complete log of this run can be found in:
7:26:45 AM: npm ERR! /opt/buildhome/.npm/_logs/2020-12-25T13_26_45_690Z-debug.log
7:26:45 AM: ​
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: “build.command” failed
7:26:45 AM: ────────────────────────────────────────────────────────────────
7:26:45 AM: ​
7:26:45 AM: Error message
7:26:45 AM: Command failed with exit code 254: CI= npm run build
7:26:45 AM: ​
7:26:45 AM: Error location
7:26:45 AM: In Build command from Netlify app:
7:26:45 AM: CI= npm run build
7:26:45 AM: ​
7:26:45 AM: Resolved config
7:26:45 AM: build:
7:26:45 AM: command: CI= npm run build
7:26:45 AM: commandOrigin: ui
7:26:45 AM: publish: /opt/build/repo/my-portfolio/build
7:26:45 AM: Caching artifacts
7:26:45 AM: Started saving build plugins
7:26:45 AM: Finished saving build plugins
7:26:45 AM: Started saving pip cache
7:26:45 AM: Finished saving pip cache
7:26:45 AM: Started saving emacs cask dependencies
7:26:45 AM: Finished saving emacs cask dependencies
7:26:45 AM: Started saving maven dependencies
7:26:46 AM: Finished saving maven dependencies
7:26:46 AM: Started saving boot dependencies
7:26:46 AM: Finished saving boot dependencies
7:26:46 AM: Started saving rust rustup cache
7:26:46 AM: Finished saving rust rustup cache
7:26:46 AM: Started saving rust cargo bin cache
7:26:46 AM: Finished saving rust cargo bin cache
7:26:46 AM: Started saving go dependencies
7:26:46 AM: Finished saving go dependencies
7:26:48 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:26:48 AM: Failing build: Failed to build site
7:26:48 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
7:26:48 AM: Finished processing build request in 11.144965346s

Can someone please help me to fix this?

Thank you!

According to the log, there’s no package.json in the root of your repo. I did check your repo and there’s actually no package.json. So, add that file and it should work as long as there are no other errors in the code.

Thank you, I just solved it.

i am having issues deploying my site even after deleting the yarn.lock and packcage.lock filesmy repo

8:15:31 PM: Build ready to start
8:15:33 PM: build-image version: 73def8bb10593b9b818f44989a75ea508018ccb7 (focal)
8:15:33 PM: build-image tag: v4.5.2
8:15:33 PM: buildbot version: e07f38cea73012d29c839c78dec87335277fe704
8:15:34 PM: Fetching cached dependencies
8:15:34 PM: Failed to fetch cache, continuing with build
8:15:34 PM: Starting to prepare the repo for build
8:15:34 PM: No cached dependencies found. Cloning fresh repo
8:15:34 PM: git clone https://github.com/momoh001/urbangeniesnft
8:15:35 PM: Preparing Git Reference refs/heads/main
8:15:35 PM: Parsing package.json dependencies
8:15:35 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
8:15:36 PM: Starting build script
8:15:36 PM: Installing dependencies
8:15:36 PM: Python version set to 2.7
8:15:36 PM: v16.13.1 is already installed.
8:15:37 PM: Now using node v16.13.1 (npm v8.1.2)
8:15:37 PM: Started restoring cached build plugins
8:15:37 PM: Finished restoring cached build plugins
8:15:37 PM: Attempting ruby version 2.7.2, read from environment
8:15:39 PM: Using ruby version 2.7.2
8:15:39 PM: Using PHP version 8.0
8:15:39 PM: Started restoring cached go cache
8:15:39 PM: Finished restoring cached go cache
8:15:39 PM: go version go1.16.5 linux/amd64
8:15:39 PM: go version go1.16.5 linux/amd64
8:15:39 PM: Installing missing commands
8:15:39 PM: Verify run directory
8:15:41 PM: ​
8:15:41 PM: ────────────────────────────────────────────────────────────────
8:15:41 PM:   Netlify Build                                                 
8:15:41 PM: ────────────────────────────────────────────────────────────────
8:15:41 PM: ​
8:15:41 PM: ❯ Version
8:15:41 PM:   @netlify/build 26.0.2
8:15:41 PM: ​
8:15:41 PM: ❯ Flags
8:15:41 PM:   baseRelDir: true
8:15:41 PM:   buildId: 61c61c535caa39eeba464601
8:15:41 PM:   deployId: 61c61c535caa39eeba464603
8:15:41 PM: ​
8:15:41 PM: ❯ Current directory
8:15:41 PM:   /opt/build/repo
8:15:41 PM: ​
8:15:41 PM: ❯ Config file
8:15:41 PM:   No config file was defined: using default values.
8:15:41 PM: ​
8:15:41 PM: ❯ Context
8:15:41 PM:   production
8:15:41 PM: ​
8:15:41 PM: ────────────────────────────────────────────────────────────────
8:15:41 PM:   1. Build command from Netlify app                             
8:15:41 PM: ────────────────────────────────────────────────────────────────
8:15:41 PM: ​
8:15:41 PM: $ npm run build
8:15:42 PM: npm ERR! code ENOENT
8:15:42 PM: npm ERR! syscall open
8:15:42 PM: npm ERR! path /opt/build/repo/package.json
8:15:42 PM: npm ERR! errno -2
8:15:42 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'
8:15:42 PM: npm ERR! enoent This is related to npm not being able to find a file.
8:15:42 PM: npm ERR! enoent
8:15:42 PM: npm ERR! A complete log of this run can be found in:
8:15:42 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-12-24T19_15_42_418Z-debug.log
8:15:42 PM: ​
8:15:42 PM: ────────────────────────────────────────────────────────────────
8:15:42 PM:   "build.command" failed                                        
8:15:42 PM: ────────────────────────────────────────────────────────────────
8:15:42 PM: ​
8:15:42 PM:   Error message
8:15:42 PM:   Command failed with exit code 254: npm run build
8:15:42 PM: ​
8:15:42 PM:   Error location
8:15:42 PM:   In Build command from Netlify app:
8:15:42 PM:   npm run build
8:15:42 PM: ​
8:15:42 PM:   Resolved config
8:15:42 PM:   build:
8:15:42 PM:     base: /opt/build/repo
8:15:42 PM:     command: npm run build
8:15:42 PM:     commandOrigin: ui
8:15:42 PM:     publish: /opt/build/repo/build
8:15:42 PM:     publishOrigin: ui
8:15:42 PM: Caching artifacts
8:15:42 PM: Started saving build plugins
8:15:42 PM: Finished saving build plugins
8:15:42 PM: Started saving pip cache
8:15:42 PM: Finished saving pip cache
8:15:42 PM: Started saving emacs cask dependencies
8:15:42 PM: Finished saving emacs cask dependencies
8:15:42 PM: Started saving maven dependencies
8:15:42 PM: Finished saving maven dependencies
8:15:42 PM: Started saving boot dependencies
8:15:42 PM: Finished saving boot dependencies
8:15:42 PM: Started saving rust rustup cache
8:15:43 PM: Finished saving rust rustup cache
8:15:43 PM: Started saving go dependencies
8:15:43 PM: Finished saving go dependencies
8:15:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:15:45 PM: Creating deploy upload records
8:15:45 PM: Failing build: Failed to build site
8:15:45 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
8:15:45 PM: Finished processing build request in 11.615241111s

Your repo appears to be empty: