# Failed to build

**URL:** <https://answers.netlify.com/t/failed-to-build/54522>\
**Category:** Support\
**Tags:** building, netlify-newbie\
**Created:** [April 5, 2022, 11:04pm UTC](https://answers.netlify.com/t/failed-to-build/54522 "2022-04-05T23:04:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivia-cowan](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@olivia-cowan](https://answers.netlify.com/u/olivia-cowan)\
**Post date:** [April 5, 2022, 11:04pm UTC](https://answers.netlify.com/t/failed-to-build/54522/1 "2022-04-05T23:04:26Z")

</div>

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](https://github.com/oliviacowan/pill-popper)  
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](http://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](https://ntl.fyi/exit-code-2))  
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](https://ntl.fyi/exit-code-254))  
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](https://github.com/oliviacowan/pill-popper)

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

---

<div class="post-metadata">

**Author:** ![coelmay](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/coelmay/32/24427_2.png) [@coelmay](https://answers.netlify.com/u/coelmay)\
**Post date:** [April 6, 2022, 12:25am UTC](https://answers.netlify.com/t/failed-to-build/54522/2 "2022-04-06T00:25:31Z")

</div>

Hey @olivia-cowan

> [@olivia-cowan](#):
>
> npm ERR! path /opt/build/repo/package.json

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

> **[Monorepos](https://docs.netlify.com/configure-builds/monorepos/)**
>
> Set up your sites to build from a monorepo. Consider where to declare dependencies and how to use workspaces on the platform.

---

<div class="post-metadata">

**Author:** ![olivia-cowan](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@olivia-cowan](https://answers.netlify.com/u/olivia-cowan)\
**Post date:** [April 6, 2022, 12:44am UTC](https://answers.netlify.com/t/failed-to-build/54522/3 "2022-04-06T00:44:34Z")

</div>

![Screen Shot 2022-04-05 at 5.42.21 PM](https://global.discourse-cdn.com/netlify/original/3X/e/7/e7afca5b28ebc0242bd17afae8c17e40b5d9c744.png)

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

---

<div class="post-metadata">

**Author:** ![olivia-cowan](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@olivia-cowan](https://answers.netlify.com/u/olivia-cowan)\
**Post date:** [April 6, 2022, 12:45am UTC](https://answers.netlify.com/t/failed-to-build/54522/4 "2022-04-06T00:45:05Z")

</div>

![Screen Shot 2022-04-05 at 5.43.26 PM](https://global.discourse-cdn.com/netlify/original/3X/4/e/4ed5694d5d299c7899930db4a3e862a4a73ef7a3.png)

---

<div class="post-metadata">

**Author:** ![coelmay](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/coelmay/32/24427_2.png) [@coelmay](https://answers.netlify.com/u/coelmay)\
**Post date:** [April 6, 2022, 1:08am UTC](https://answers.netlify.com/t/failed-to-build/54522/5 "2022-04-06T01:08:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![olivia-cowan](https://avatars.discourse-cdn.com/v4/letter/o/6bbea6/32.png) [@olivia-cowan](https://answers.netlify.com/u/olivia-cowan)\
**Post date:** [April 6, 2022, 1:40am UTC](https://answers.netlify.com/t/failed-to-build/54522/6 "2022-04-06T01:40:06Z")

</div>

that was it thank you!!
