“build.command” failed . i have tried CI= npm run build

I just get error “build.command” failed. I added the command CI= npm run build and still the error continues.

My application is in Angular, I don’t know what else to do, I am waiting for your help.
Thanks in advance.

5:29:19 PM: Build ready to start

5:29:21 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6

5:29:21 PM: build-image tag: v3.4.1

5:29:21 PM: buildbot version: 648208d76731cd5bca75c1e9bc99d2032a1f1473

5:29:21 PM: Fetching cached dependencies

5:29:21 PM: Failed to fetch cache, continuing with build

5:29:21 PM: Starting to prepare the repo for build

5:29:21 PM: No cached dependencies found. Cloning fresh repo

5:29:21 PM: git clone https://github.com/PabloFerreiraB/Aposentaf-ms

5:29:25 PM: Preparing Git Reference refs/heads/master

5:29:26 PM: Starting build script

5:29:26 PM: Installing dependencies

5:29:26 PM: Python version set to 2.7

5:29:27 PM: v12.18.0 is already installed.

5:29:28 PM: Now using node v12.18.0 (npm v6.14.4)

5:29:28 PM: Started restoring cached build plugins

5:29:28 PM: Finished restoring cached build plugins

5:29:28 PM: Attempting ruby version 2.7.1, read from environment

5:29:30 PM: Using ruby version 2.7.1

5:29:30 PM: Using PHP version 5.6

5:29:30 PM: 5.2 is already installed.

5:29:30 PM: Using Swift version 5.2

5:29:30 PM: Started restoring cached go cache

5:29:30 PM: Finished restoring cached go cache

5:29:30 PM: go version go1.14.4 linux/amd64

5:29:30 PM: go version go1.14.4 linux/amd64

5:29:30 PM: Installing missing commands

5:29:30 PM: Verify run directory

5:29:31 PM: ​

5:29:31 PM: ┌─────────────────────────────┐

5:29:31 PM: │ Netlify Build │

5:29:31 PM: └─────────────────────────────┘

5:29:31 PM: ​

5:29:31 PM: ❯ Version

5:29:31 PM: @netlify/build 4.0.4

5:29:31 PM: ​

5:29:31 PM: ❯ Flags

5:29:31 PM: deployId: 5f70f61f879ac7239dd431e5

5:29:31 PM: mode: buildbot

5:29:31 PM: ​

5:29:31 PM: ❯ Current directory

5:29:31 PM: /opt/build/repo

5:29:31 PM: ​

5:29:31 PM: ❯ Config file

5:29:31 PM: No config file was defined: using default values.

5:29:31 PM: ​

5:29:31 PM: ❯ Context

5:29:31 PM: production

5:29:31 PM: ​

5:29:31 PM: ┌───────────────────────────────────┐

5:29:31 PM: │ 1. Build command from Netlify app │

5:29:31 PM: └───────────────────────────────────┘

5:29:31 PM: ​

5:29:31 PM: $ CI= npm run build

5:29:32 PM: npm ERR! code ENOENT

5:29:32 PM: npm ERR! syscall open

5:29:32 PM: npm ERR! path /opt/build/repo/package.json

5:29:32 PM: npm ERR! errno -2

5:29:32 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json'

5:29:32 PM: npm ERR! enoent This is related to npm not being able to find a file.

5:29:32 PM: npm ERR! enoent

5:29:32 PM: npm ERR! A complete log of this run can be found in:

5:29:32 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-09-27T20_29_32_260Z-debug.log

5:29:32 PM: ​

5:29:32 PM: ┌─────────────────────────────┐

5:29:32 PM: │ "build.command" failed │

5:29:32 PM: └─────────────────────────────┘

5:29:32 PM: ​

5:29:32 PM: Error message

5:29:32 PM: Command failed with exit code 254: CI= npm run build

5:29:32 PM: ​

5:29:32 PM: Error location

5:29:32 PM: In Build command from Netlify app:

5:29:32 PM: CI= npm run build

5:29:32 PM: ​

5:29:32 PM: Resolved config

5:29:32 PM: build:

5:29:32 PM: command: CI= npm run build

5:29:32 PM: commandOrigin: ui

5:29:32 PM: publish: /opt/build/repo/dist/APP

5:29:32 PM: Caching artifacts

5:29:32 PM: Started saving build plugins

5:29:32 PM: Finished saving build plugins

5:29:32 PM: Started saving pip cache

5:29:32 PM: Finished saving pip cache

5:29:32 PM: Started saving emacs cask dependencies

5:29:32 PM: Finished saving emacs cask dependencies

5:29:32 PM: Started saving maven dependencies

5:29:32 PM: Finished saving maven dependencies

5:29:32 PM: Started saving boot dependencies

5:29:32 PM: Finished saving boot dependencies

5:29:32 PM: Started saving go dependencies

5:29:32 PM: Finished saving go dependencies

5:29:35 PM: Error running command: Build script returned non-zero exit code: 2

5:29:35 PM: Failing build: Failed to build site

5:29:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2

5:29:35 PM: Finished processing build request in 14.748978179s

Hi, @PabloFerreira. The error is this:

npm ERR! path /opt/build/repo/package.json

The node runtime is saying that package.json doesn’t exist. This is because it doesn’t exist in the repo (this is a 404 page below):

https://github.com/PabloFerreiraB/Aposentaf-ms/blob/master/package.json

There is a package-lock.json file but it is almost empty:

To be able to call a package.json script using npm (for example using npm run build), first that script (build in this example) must be defined in package.json. That has not been done and the error is saying the required file is missing.

Also, the following support guide might be helpful here as well:

​Please let us know if there are other questions about this.