# Command failed with exit code 254: CI= npm run build (https://ntl.fyi/exit-code-254)

**URL:** <https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519>\
**Category:** Support\
**Tags:** building\
**Created:** [April 5, 2022, 9:27pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519 "2022-04-05T21:27:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewbidylo](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@andrewbidylo](https://answers.netlify.com/u/andrewbidylo)\
**Post date:** [April 5, 2022, 9:27pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/1 "2022-04-05T21:27:01Z")

</div>

Problem with build

1:57:11 PM: Waiting for other deploys from your team to complete. Check the queue: [Netlify App](https://app.netlify.com/teams/mrman511/builds)  
1:57:32 PM: Build ready to start  
1:57:38 PM: build-image version: d2c6dbeac570350a387d832f64bc980dc964ad65 (focal)  
1:57:38 PM: build-image tag: v4.8.0  
1:57:38 PM: buildbot version: e552b142336b2b1222a93a4fd4cbed0019c77b46  
1:57:38 PM: Fetching cached dependencies  
1:57:38 PM: Starting to download cache of 187.4MB  
1:57:40 PM: Finished downloading cache in 1.986926042s  
1:57:40 PM: Starting to extract cache  
1:57:46 PM: Finished extracting cache in 5.939745876s  
1:57:46 PM: Finished fetching cache in 7.951498793s  
1:57:46 PM: Starting to prepare the repo for build  
1:57:46 PM: Preparing Git Reference pull/103/head  
1:57:47 PM: Parsing package.json dependencies  
1:57:47 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘’ versus ‘front-end’ in the Netlify UI  
1:57:47 PM: Starting build script  
1:57:47 PM: Installing dependencies  
1:57:47 PM: Python version set to 2.7  
1:57:47 PM: Started restoring cached node version  
1:57:49 PM: Finished restoring cached node version  
1:57:49 PM: v16.14.2 is already installed.  
1:57:49 PM: Now using node v16.14.2 (npm v8.5.0)  
1:57:49 PM: Started restoring cached build plugins  
1:57:49 PM: Finished restoring cached build plugins  
1:57:50 PM: Attempting ruby version 2.7.2, read from environment  
1:57:51 PM: Using ruby version 2.7.2  
1:57:51 PM: Using PHP version 8.0  
1:57:51 PM: Started restoring cached go cache  
1:57:51 PM: Finished restoring cached go cache  
1:57:51 PM: go version go1.16.5 linux/amd64  
1:57:51 PM: go version go1.16.5 linux/amd64  
1:57:51 PM: Installing missing commands  
1:57:51 PM: Verify run directory  
1:57:52 PM: ​  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: Netlify Build  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: ​  
1:57:52 PM: ❯ Version  
1:57:52 PM: @netlify/build 26.5.2  
1:57:52 PM: ​  
1:57:52 PM: ❯ Flags  
1:57:52 PM: baseRelDir: true  
1:57:52 PM: buildId: 624cad27cd438a0009b26651  
1:57:52 PM: deployId: 624cad27cd438a0009b26653  
1:57:52 PM: ​  
1:57:52 PM: ❯ Current directory  
1:57:52 PM: /opt/build/repo  
1:57:52 PM: ​  
1:57:52 PM: ❯ Config file  
1:57:52 PM: No config file was defined: using default values.  
1:57:52 PM: ​  
1:57:52 PM: ❯ Context  
1:57:52 PM: deploy-preview  
1:57:52 PM: ​  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: 1. Build command from Netlify app  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: ​  
1:57:52 PM: $ CI= npm run build  
1:57:52 PM: npm ERR! code ENOENT  
1:57:52 PM: npm ERR! syscall open  
1:57:52 PM: npm ERR! path /opt/build/repo/package.json  
1:57:52 PM: npm ERR! errno -2  
1:57:52 PM: npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’  
1:57:52 PM: npm ERR! enoent This is related to npm not being able to find a file.  
1:57:52 PM: npm ERR! enoent  
1:57:52 PM: npm ERR! A complete log of this run can be found in:  
1:57:52 PM: npm ERR! /opt/buildhome/.npm/\_logs/2022-04-05T20\_57\_52\_764Z-debug-0.log  
1:57:52 PM: ​  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: “build.command” failed  
1:57:52 PM: ────────────────────────────────────────────────────────────────  
1:57:52 PM: ​  
1:57:52 PM: Error message  
1:57:52 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))  
1:57:52 PM: ​  
1:57:52 PM: Error location  
1:57:52 PM: In Build command from Netlify app:  
1:57:52 PM: CI= npm run build  
1:57:52 PM: ​  
1:57:52 PM: Resolved config  
1:57:52 PM: build:  
1:57:52 PM: base: /opt/build/repo  
1:57:52 PM: command: CI= npm run build  
1:57:52 PM: commandOrigin: ui  
1:57:52 PM: environment:  
1:57:52 PM: - REACT\_APP\_API\_BASE\_URL  
1:57:52 PM: - REACT\_APP\_GOOGLE\_KEY  
1:57:52 PM: - REVIEW\_ID  
1:57:52 PM: publish: /opt/build/repo/build  
1:57:52 PM: publishOrigin: ui  
1:57:53 PM: Caching artifacts  
1:57:53 PM: Started saving node modules  
1:57:55 PM: Finished saving node modules  
1:57:55 PM: Started saving build plugins  
1:57:55 PM: Finished saving build plugins  
1:57:55 PM: Started saving pip cache  
1:57:55 PM: Finished saving pip cache  
1:57:55 PM: Started saving emacs cask dependencies  
1:57:55 PM: Creating deploy upload records  
1:57:55 PM: Finished saving emacs cask dependencies  
1:57:55 PM: Started saving maven dependencies  
1:57:55 PM: Finished saving maven dependencies  
1:57:55 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))  
1:57:55 PM: Started saving boot dependencies  
1:57:55 PM: Finished saving boot dependencies  
1:57:55 PM: Started saving rust rustup cache  
1:57:55 PM: Finished saving rust rustup cache  
1:57:55 PM: Started saving go dependencies  
1:57:55 PM: Finished saving go dependencies  
1:57:55 PM: Build failed due to a user error: Build script returned non-zero exit code: 2  
1:57:55 PM: Failing build: Failed to build site

---

<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 5, 2022, 9:35pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/2 "2022-04-05T21:35:32Z")

</div>

Hey @andrewbidylo

> [@andrewbidylo](#):
>
> npm ERR! enoent ENOENT: no such file or directory, open ‘/opt/build/repo/package.json’

The error here is there is no `package.json` in the root of the repository. Does the code you wish to build exist at the repository root or in a sub-directory?

You can find further troubleshooting assistance via

> [@\[Support Guide\] Frequently encountered problems during builds](https://answers.netlify.com/t/support-guide-frequently-encountered-problems-during-builds/213):
>
> Last reviewed by Netlify Support - July 2025 Overview Sites on Netlify can be built using a variety of tools — different frameworks, programming languages and approaches. It can be incredibly frustrating to see your site fail to build! If you have a build on Netlify that is failing with an error message that you don’t understand, you are not alone. Here you’ll find some common build failure messages, and probable solutions to their causes. If you’re looking for more general information on build…

and also

> [@\[Support Guide\] Compiled Build and Deploy Resources -- start here!](https://answers.netlify.com/t/support-guide-compiled-build-and-deploy-resources-start-here/50679):
>
> Last reviewed by Netlify Support in July 2025 We want to help you build and deploy your site as easily as possible. Our team has written numerous support guides on frequently encountered problems during builds, build/deploy behaviour, drag and drop deploys, and more. In an effort to streamline your searching, we have compiled a list of our Support Guides related to builds and deploys. Each guide contains a ton of useful debugging tips that can likely help you solve your problem. Troubleshootin…

---

<div class="post-metadata">

**Author:** ![andrewbidylo](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@andrewbidylo](https://answers.netlify.com/u/andrewbidylo)\
**Post date:** [April 5, 2022, 9:41pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/3 "2022-04-05T21:41:27Z")

</div>

Yeah, my `package.json` in the sub-directory ‘front-end’

---

<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 5, 2022, 9:42pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/4 "2022-04-05T21:42:35Z")

</div>

Then you need to set the _base directory_ to `front-end` as per [this documentation](https://docs.netlify.com/configure-builds/monorepos/)

---

<div class="post-metadata">

**Author:** ![andrewbidylo](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@andrewbidylo](https://answers.netlify.com/u/andrewbidylo)\
**Post date:** [April 5, 2022, 9:47pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/5 "2022-04-05T21:47:16Z")

</div>

I’ve already tried it.

 ![Screen_Shot_2022-04-05_at_2.44.31_PM](https://global.discourse-cdn.com/netlify/original/3X/3/5/354023546c86517e787424fac45c2d354dbfb34b.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 5, 2022, 9:49pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/6 "2022-04-05T21:49:35Z")

</div>

And do you receive the same deploy error after changing the _base directory_?

---

<div class="post-metadata">

**Author:** ![andrewbidylo](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@andrewbidylo](https://answers.netlify.com/u/andrewbidylo)\
**Post date:** [April 5, 2022, 9:52pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/7 "2022-04-05T21:52:28Z")

</div>

I’ve got this error when I already had these settings.

---

<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 5, 2022, 10:07pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/8 "2022-04-05T22:07:13Z")

</div>

Can you share the repository?

---

<div class="post-metadata">

**Author:** ![andrewbidylo](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@andrewbidylo](https://answers.netlify.com/u/andrewbidylo)\
**Post date:** [April 7, 2022, 10:33pm UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/9 "2022-04-07T22:33:23Z")

</div>

sure. [GitHub - mrman511/pill-popper at Production](https://github.com/mrman511/pill-popper/tree/Production)

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [April 8, 2022, 3:02am UTC](https://answers.netlify.com/t/command-failed-with-exit-code-254-ci-npm-run-build-https-ntl-fyi-exit-code-254/54519/10 "2022-04-08T03:02:46Z")

</div>

You are overriding the base build directory. It shows this in the logs here:

```plaintext
1:57:47 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: ‘’ versus ‘front-end’ in the Netlify UI

```

To fix this, correct the setting in `netlify.toml` here:

> <https://github.com/mrman511/pill-popper/blob/main/front-end/netlify.toml#L4>

You can either delete that line or change it to

```plaintext
  base = "front-end"

```
