Home
Support Forums

My site is up and running, but Netlify says the build failed

Hello Netlify community,
My problem is that I built a DApp using the Hashlips nft minting dapp repo. I put all the correct info in and created the build. The build is now a private repo on github. I purchased www.bittynft.com from godaddy, changed the name serveres, and the site works. I can go to bittynft.com connect my wallet and mint nfts, but on the netlify site it says my build failed.
The netlify site name is friendly-wright-f18599.netlify.app and the custom domain is www.bittynft.com.
I’m not 100% sure what’s going wrong, and what consequences these errors might cause. The error code is: β€œBuild failed due to a user error: Build script returned non-zero exit code: 2”

here’s the log thanks for the help:

9:25:01 AM: Build ready to start
9:25:03 AM: build-image version: 73def8bb10593b9b818f44989a75ea508018ccb7 (focal)
9:25:03 AM: build-image tag: v4.5.2
9:25:03 AM: buildbot version: ff9e2433dccff2a568f42fdd27a8e92c84c8a325
9:25:03 AM: Fetching cached dependencies
9:25:04 AM: Failed to fetch cache, continuing with build
9:25:04 AM: Starting to prepare the repo for build
9:25:04 AM: No cached dependencies found. Cloning fresh repo
9:25:04 AM: git clone https://github.com/BittyNFT/DApp
9:25:05 AM: Preparing Git Reference refs/heads/main
9:25:06 AM: Parsing package.json dependencies
9:25:06 AM: Different build dir detected, going to use the one specified in the Netlify configuration file: β€˜β€™ versus β€˜/’ in the Netlify UI
9:25:06 AM: Starting build script
9:25:06 AM: Installing dependencies
9:25:06 AM: Python version set to 2.7
9:25:07 AM: v16.13.1 is already installed.
9:25:08 AM: Now using node v16.13.1 (npm v8.1.2)
9:25:08 AM: Started restoring cached build plugins
9:25:08 AM: Finished restoring cached build plugins
9:25:08 AM: Attempting ruby version 2.7.2, read from environment
9:25:09 AM: Using ruby version 2.7.2
9:25:09 AM: Using PHP version 8.0
9:25:09 AM: Started restoring cached go cache
9:25:09 AM: Finished restoring cached go cache
9:25:09 AM: go version go1.16.5 linux/amd64
9:25:09 AM: go version go1.16.5 linux/amd64
9:25:09 AM: Installing missing commands
9:25:09 AM: Verify run directory
9:25:11 AM: ​
9:25:11 AM: ────────────────────────────────────────────────────────────────
9:25:11 AM: Netlify Build
9:25:11 AM: ────────────────────────────────────────────────────────────────
9:25:11 AM: ​
9:25:11 AM: ❯ Version
9:25:11 AM: @netlify/build 26.1.0
9:25:11 AM: ​
9:25:11 AM: ❯ Flags
9:25:11 AM: baseRelDir: true
9:25:11 AM: buildId: 61d725ed0990b35f6cc08be4
9:25:11 AM: deployId: 61d725ed0990b35f6cc08be6
9:25:11 AM: ​
9:25:11 AM: ❯ Current directory
9:25:11 AM: /opt/build/repo
9:25:11 AM: ​
9:25:11 AM: ❯ Config file
9:25:11 AM: No config file was defined: using default values.
9:25:11 AM: ​
9:25:11 AM: ❯ Context
9:25:11 AM: production
9:25:11 AM: ​
9:25:11 AM: ────────────────────────────────────────────────────────────────
9:25:11 AM: 1. Build command from Netlify app
9:25:11 AM: ────────────────────────────────────────────────────────────────
9:25:11 AM: ​
9:25:11 AM: $ CI= npm run build
9:25:12 AM: npm ERR! code ENOENT
9:25:12 AM: npm ERR! syscall open
9:25:12 AM: npm ERR! path /opt/build/repo/package.json
9:25:12 AM: npm ERR! errno -2
9:25:12 AM: npm ERR! enoent ENOENT: no such file or directory, open β€˜/opt/build/repo/package.json’
9:25:12 AM: npm ERR! enoent This is related to npm not being able to find a file.
9:25:12 AM: npm ERR! enoent
9:25:12 AM: npm ERR! A complete log of this run can be found in:
9:25:12 AM: npm ERR! /opt/buildhome/.npm/_logs/2022-01-06T17_25_12_024Z-debug.log
9:25:12 AM: ​
9:25:12 AM: ────────────────────────────────────────────────────────────────
9:25:12 AM: β€œbuild.command” failed
9:25:12 AM: ────────────────────────────────────────────────────────────────
9:25:12 AM: ​
9:25:12 AM: Error message
9:25:12 AM: Command failed with exit code 254: CI= npm run build
9:25:12 AM: ​
9:25:12 AM: Error location
9:25:12 AM: In Build command from Netlify app:
9:25:12 AM: CI= npm run build
9:25:12 AM: ​
9:25:12 AM: Resolved config
9:25:12 AM: build:
9:25:12 AM: base: /opt/build/repo
9:25:12 AM: command: CI= npm run build
9:25:12 AM: commandOrigin: ui
9:25:12 AM: environment:
9:25:12 AM: - CI
9:25:12 AM: publish: /opt/build/repo/build
9:25:12 AM: publishOrigin: ui
9:25:12 AM: Caching artifacts
9:25:12 AM: Started saving build plugins
9:25:12 AM: Finished saving build plugins
9:25:12 AM: Started saving pip cache
9:25:12 AM: Finished saving pip cache
9:25:12 AM: Started saving emacs cask dependencies
9:25:12 AM: Finished saving emacs cask dependencies
9:25:12 AM: Started saving maven dependencies
9:25:12 AM: Finished saving maven dependencies
9:25:12 AM: Started saving boot dependencies
9:25:12 AM: Finished saving boot dependencies
9:25:12 AM: Started saving rust rustup cache
9:25:12 AM: Finished saving rust rustup cache
9:25:12 AM: Started saving go dependencies
9:25:12 AM: Finished saving go dependencies
9:25:14 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:25:15 AM: Creating deploy upload records
9:25:15 AM: Failing build: Failed to build site
9:25:15 AM: Failed during stage β€˜building site’: Build script returned non-zero exit code: 2
9:25:15 AM: Finished processing build request in 11.583370085s

hi there, did you have a previously working build? or is this the first time you have tried to build and deploy?

you might give this thread a read through:

Hello, This is the first time I have tried to build and deploy. I have deployed the site on my local network using visual studio code on my laptop, and the hashlips nft minting dapp. Everything works, I am able to connect to my wallet and mint an NFT, the site is even live and accessible and live to the public, but netlify still says that the build failed.

I have read the thread you suggested, and I also have no package.json It’s possible the file is named something else. The only other .json file in the directory is named β€œmanifest” is it possible I just need to rename this file?

Hi @BIttyNFT

If you have no package.json the likely you do not need the build command you are using. Is there a directory in the git repository (private so I can’t check myself) called build? If this directory exists in the repository, that is what Netlify is publishing and why the site works.

If you are pushing the built site to git and not the codebase, then you should remove the build command and base directory leaving only build as the value for the publish directory.

1 Like

Hello @coelmay
Thank you for the suggestion. I changed the build directory to nothing, and it still doesn’t run.

Without seeing the repository, it is impossible to make further suggestions.


does this help or do I need to make it public?

The screenshot is fine in this instance.

If that is the root of the repository, and that is all that exists in the repository, there is nothing to build. You do NOT need the build command and the publish directory is the repository root (not build.)

However based on what is currently deployed at www.bittynft.com there is something amiss as is it built using React, and what I see in the repository currently is what would exist by default in the public directory of a React App project.

You can find a basic React repository coelmay/netlify-react-bare which uses the following build settings

(Note the files in the public directory are those in your screenshot.)

I have tried changing the settings as suggested, but I’m still getting an error message when it goes looking for the package.json file. The site is up and running. It appears to work, so I guess I’ll just leave well enough alone until it becomes a problem.
Thanks

Because you have a build command you need to have a package.json file in the repository. You do NOT have a package.json in the repository which is why the build continually fails.