Failed to build

PLEASE help us help you by writing a good post!

  • we need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot

The better the post - the faster the answer.

3:58:44 PM: Build ready to start
3:58:46 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)
3:58:46 PM: build-image tag: v4.8.0
3:58:46 PM: buildbot version: e552b142336b2b1222a93a4fd4cbed0019c77b46
3:58:47 PM: Fetching cached dependencies
3:58:47 PM: Failed to fetch cache, continuing with build
3:58:47 PM: Starting to prepare the repo for build
3:58:47 PM: No cached dependencies found. Cloning fresh repo
3:58:47 PM: git clone GitHub - oliviacowan/pill-popper: final project for lighthouse labs
3:58:48 PM: Preparing Git Reference refs/heads/main
3:58:48 PM: Parsing package.json dependencies
3:58:53 PM: Failed to generate package.json data, continuing with build
3:58:54 PM:

❯ Initial build environment
baseRelDir: true
branch: main
context: production
cwd: /opt/build/repo
featureFlags:
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 11db43be-b334-4867-90cb-da46ad14eae3

❯ UI build settings
baseRelDir: true
build:
base: /front-end
command: CI= npm run build
environment:
- CI
- NETLIFY_BUILD_DEBUG
publish: build/

❯ Resolved build environment
branch: main
buildDir: /opt/build/repo
context: production
env:

❯ Resolved config
build:
base: /opt/build/repo
command: CI= npm run build
commandOrigin: ui
environment:
- CI
- NETLIFY_BUILD_DEBUG
publish: /opt/build/repo/build
publishOrigin: ui

3:58:54 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘’ versus ‘/front-end’ in the Netlify UI
3:58:54 PM: Starting build script
3:58:54 PM: Installing dependencies
3:58:54 PM: Python version set to 2.7
3:58:55 PM: v16.14.2 is already installed.
3:58:55 PM: Now using node v16.14.2 (npm v8.5.0)
3:58:55 PM: Started restoring cached build plugins
3:58:55 PM: Finished restoring cached build plugins
3:58:55 PM: Attempting ruby version 2.7.2, read from environment
3:58:56 PM: Using ruby version 2.7.2
3:58:56 PM: Using PHP version 8.0
3:58:56 PM: Started restoring cached go cache
3:58:56 PM: Finished restoring cached go cache
3:58:56 PM: go version go1.16.5 linux/amd64
3:58:56 PM: go version go1.16.5 linux/amd64
3:58:56 PM: Installing missing commands
3:58:56 PM: Verify run directory
3:58:58 PM: ​
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: Netlify Build
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: ​
3:58:58 PM: ❯ Version
3:58:58 PM: @netlify/build 26.5.2
3:58:58 PM: ​
3:58:58 PM: ❯ Flags
3:58:58 PM: apiHost: api-aws.netlify.com
3:58:58 PM: baseRelDir: true
3:58:58 PM: branch: main
3:58:58 PM: buildId: 624cc9a469e4b60a5b9e74d5
3:58:58 PM: buildbotServerSocket: /tmp/netlify-buildbot-socket
3:58:58 PM: cacheDir: /opt/build/cache
3:58:58 PM: cachedConfigPath: /tmp/netlify_config.json
3:58:58 PM: context: production
3:58:58 PM: cwd: /opt/build/repo
3:58:58 PM: deployId: 624cc9a469e4b60a5b9e74d7
3:58:58 PM: featureFlags:
3:58:58 PM: - buildbot_build_go_functions
3:58:58 PM: - zisi_parse_isc
3:58:58 PM: framework: unknown
3:58:58 PM: functionsDistDir: /tmp/zisi-624cc9a469e4b60a5b9e74d7
3:58:58 PM: mode: buildbot
3:58:58 PM: nodePath: /opt/buildhome/.nvm/versions/node/v16.14.2/bin/node
3:58:58 PM: repositoryRoot: /opt/build/repo
3:58:58 PM: saveConfig: true
3:58:58 PM: sendStatus: true
3:58:58 PM: siteId: 11db43be-b334-4867-90cb-da46ad14eae3
3:58:58 PM: statsd:
3:58:58 PM: host: 10.65.149.251
3:58:58 PM: port: 8125
3:58:58 PM: testOpts:
3:58:58 PM: silentLingeringProcesses: ‘’
3:58:58 PM: ​
3:58:58 PM: ❯ Current directory
3:58:58 PM: /opt/build/repo
3:58:58 PM: ​
3:58:58 PM: ❯ Config file
3:58:58 PM: No config file was defined: using default values.
3:58:58 PM: ​
3:58:58 PM: ❯ Resolved config
3:58:58 PM: build:
3:58:58 PM: base: /opt/build/repo
3:58:58 PM: command: CI= npm run build
3:58:58 PM: commandOrigin: ui
3:58:58 PM: environment:
3:58:58 PM: - CI
3:58:58 PM: - NETLIFY_BUILD_DEBUG
3:58:58 PM: publish: /opt/build/repo/build
3:58:58 PM: publishOrigin: ui
3:58:58 PM: ​
3:58:58 PM: ❯ Context
3:58:58 PM: production
3:58:58 PM: ​
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: 1. Build command from Netlify app
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: ​
3:59:00 PM: Creating deploy upload records
3:58:58 PM: $ CI= npm run build
3:58:58 PM: npm ERR! code ENOENT
3:58:58 PM: npm ERR! syscall open
3:58:58 PM: npm ERR! path /opt/build/repo/package.json
3:58:58 PM: npm ERR! errno -2
3:59:00 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
3:58:58 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’
3:58:58 PM: npm ERR! enoent This is related to npm not being able to find a file.
3:58:58 PM: npm ERR! enoent
3:58:58 PM: npm ERR! A complete log of this run can be found in:
3:58:58 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-04-05T22_58_58_345Z-debug-0.log
3:58:58 PM: ​
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: “build.command” failed
3:58:58 PM: ────────────────────────────────────────────────────────────────
3:58:58 PM: ​
3:58:58 PM: Error message
3:58:58 PM: Command failed with exit code 254: CI= npm run build (Search results for '"non-zero exit code: 254"' - Netlify Support Forums)
3:58:58 PM: ​
3:58:58 PM: Error location
3:58:58 PM: In Build command from Netlify app:
3:58:58 PM: CI= npm run build
3:58:58 PM: ​
3:58:58 PM: Resolved config
3:58:58 PM: build:
3:58:58 PM: base: /opt/build/repo
3:58:58 PM: command: CI= npm run build
3:58:58 PM: commandOrigin: ui
3:58:58 PM: environment:
3:58:58 PM: - CI
3:58:58 PM: - NETLIFY_BUILD_DEBUG
3:58:58 PM: publish: /opt/build/repo/build
3:58:58 PM: publishOrigin: ui
3:58:58 PM: Caching artifacts
3:58:58 PM: Started saving node modules
3:58:58 PM: Finished saving node modules
3:58:58 PM: Started saving build plugins
3:58:58 PM: Finished saving build plugins
3:58:58 PM: Started saving pip cache
3:58:58 PM: Finished saving pip cache
3:58:58 PM: Started saving emacs cask dependencies
3:58:59 PM: Finished saving emacs cask dependencies
3:58:59 PM: Started saving maven dependencies
3:58:59 PM: Finished saving maven dependencies
3:58:59 PM: Started saving boot dependencies
3:58:59 PM: Finished saving boot dependencies
3:58:59 PM: Started saving rust rustup cache
3:58:59 PM: Finished saving rust rustup cache
3:58:59 PM: Started saving go dependencies
3:58:59 PM: Finished saving go dependencies
3:59:00 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:59:00 PM: Failing build: Failed to build site
3:59:00 PM: Finished processing build request in 13.800804859s

git repo: GitHub - oliviacowan/pill-popper: final project for lighthouse labs

I haven’t yet successfully built so I believe I don’t have a URL for it

Hey @olivia-cowan

There is no package.json (as per above error message) in the root of the repository. I might presume you are wishing to deploy the front end of an app (likely contained in the front-end directory) thus you need to set the base directory as outlined in the Monorepo documentaion

Screen Shot 2022-04-05 at 5.42.21 PM

sorry, i forgot to include these before. Am I missing something in them?

Try removing the base from the netlify.toml in the front-end directory.

that was it thank you!!

1 Like