Build.command failed when trying to deploy site for the first time

Hello I am trying to deploy a site for the first time, I stumbled across netlfiy and thought the git integration was cool so I tried deploying but had an issue. I pasted the deploy log below still new to this so not very sure what the issue is. Any help will be appreciated.

9:16:37 PM: Build ready to start
9:16:39 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
9:16:39 PM: build-image tag: v4.5.3
9:16:39 PM: buildbot version: 96522259b56227ab6642290e1a540b326f0458b4
9:16:39 PM: Fetching cached dependencies
9:16:39 PM: Failed to fetch cache, continuing with build
9:16:39 PM: Starting to prepare the repo for build
9:16:40 PM: No cached dependencies found. Cloning fresh repo
9:16:40 PM: git clone GitHub - Johnnnyy6/WebPortfolio
9:16:40 PM: Preparing Git Reference refs/heads/main
9:16:41 PM: Parsing package.json dependencies
9:16:42 PM: Starting build script
9:16:42 PM: Installing dependencies
9:16:42 PM: Python version set to 2.7
9:16:43 PM: Downloading and installing node v16.14.0…
9:16:43 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz
9:16:43 PM: Computing checksum with sha256sum
9:16:44 PM: Checksums matched!
9:16:48 PM: Now using node v16.14.0 (npm v8.3.1)
9:16:48 PM: Started restoring cached build plugins
9:16:48 PM: Finished restoring cached build plugins
9:16:48 PM: Attempting ruby version 2.7.2, read from environment
9:16:50 PM: Using ruby version 2.7.2
9:16:50 PM: Using PHP version 8.0
9:16:50 PM: Started restoring cached go cache
9:16:50 PM: Finished restoring cached go cache
9:16:50 PM: go version go1.16.5 linux/amd64
9:16:50 PM: go version go1.16.5 linux/amd64
9:16:50 PM: Installing missing commands
9:16:50 PM: Verify run directory
9:16:52 PM: ​
9:16:52 PM: ────────────────────────────────────────────────────────────────
9:16:52 PM: Netlify Build
9:16:52 PM: ────────────────────────────────────────────────────────────────
9:16:52 PM: ​
9:16:52 PM: ❯ Version
9:16:52 PM: @netlify/build 26.2.6
9:16:52 PM: ​
9:16:52 PM: ❯ Flags
9:16:52 PM: baseRelDir: true
9:16:52 PM: buildId: 620491a5a0736833c8bce467
9:16:52 PM: deployId: 620491a5a0736833c8bce469
9:16:52 PM: ​
9:16:52 PM: ❯ Current directory
9:16:52 PM: /opt/build/repo
9:16:52 PM: ​
9:16:52 PM: ❯ Config file
9:16:52 PM: No config file was defined: using default values.
9:16:52 PM: ​
9:16:52 PM: ❯ Context
9:16:52 PM: production
9:16:52 PM: ​
9:16:52 PM: ────────────────────────────────────────────────────────────────
9:16:52 PM: 1. Build command from Netlify app
9:16:52 PM: ────────────────────────────────────────────────────────────────
9:16:52 PM: ​
9:16:52 PM: $ CI= npm run build
9:16:53 PM: npm ERR! code ENOENT
9:16:53 PM: npm ERR! syscall open
9:16:53 PM: npm ERR! path /opt/build/repo/package.json
9:16:53 PM: npm ERR! errno -2
9:16:53 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
9:16:53 PM: npm ERR! enoent This is related to npm not being able to find a file.
9:16:53 PM: npm ERR! enoent
9:16:53 PM: npm ERR! A complete log of this run can be found in:
9:16:53 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-02-10T04_16_53_097Z-debug-0.log
9:16:53 PM: ​
9:16:53 PM: ────────────────────────────────────────────────────────────────
9:16:53 PM: “build.command” failed
9:16:53 PM: ────────────────────────────────────────────────────────────────
9:16:53 PM: ​
9:16:53 PM: Error message
9:16:53 PM: Command failed with exit code 254: CI= npm run build
9:16:53 PM: ​
9:16:53 PM: Error location
9:16:53 PM: In Build command from Netlify app:
9:16:53 PM: CI= npm run build
9:16:53 PM: ​
9:16:53 PM: Resolved config
9:16:53 PM: build:
9:16:53 PM: command: CI= npm run build
9:16:53 PM: commandOrigin: ui
9:16:53 PM: publish: /opt/build/repo/build
9:16:53 PM: publishOrigin: ui
9:16:53 PM: Caching artifacts
9:16:53 PM: Started saving build plugins
9:16:53 PM: Finished saving build plugins
9:16:53 PM: Started saving pip cache
9:16:53 PM: Finished saving pip cache
9:16:53 PM: Started saving emacs cask dependencies
9:16:53 PM: Finished saving emacs cask dependencies
9:16:53 PM: Started saving maven dependencies
9:16:53 PM: Finished saving maven dependencies
9:16:53 PM: Started saving boot dependencies
9:16:53 PM: Finished saving boot dependencies
9:16:53 PM: Started saving rust rustup cache
9:16:53 PM: Finished saving rust rustup cache
9:16:53 PM: Started saving go dependencies
9:16:53 PM: Finished saving go dependencies
9:16:56 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:16:56 PM: Creating deploy upload records
9:16:56 PM: Failing build: Failed to build site
9:16:56 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
9:16:56 PM: Finished processing build request in 17.320540364s

Hey @Johnnnyy6

This message from the log is saying there is no package.json file in the repository root. The package.json exists in the sub-directory mywebsite.

There are two options:

  1. Move everything inside mywebsite up one level to the root of the repository.
  2. Set the base directory to mywebsite as per the Build from a subdirectory or monorepo documentation.