Deploy directory 'build' does not exist for create react app

Netlify Site Name

Repo

This is a create react app.

It works locally.
I tried renaming my build command and I reset the cache on Netlify.com

Full build Log

7:36:03 PM: Build ready to start
7:36:05 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
7:36:05 PM: build-image tag: v3.4.1
7:36:05 PM: buildbot version: bca3bbf1ce7c7ca2e2192b1683becc1d98c88c5b
7:36:05 PM: No cache source specified, skip fetching cache
7:36:05 PM: Starting to prepare the repo for build
7:36:06 PM: No cached dependencies found. Cloning fresh repo
7:36:06 PM: git clone https://github.com/Fullchee/values-client
7:36:07 PM: Preparing Git Reference refs/heads/master
7:36:08 PM: No build command found, continuing to publishing
7:36:08 PM: Failing build: Failed to build site
7:36:08 PM: Failed during stage 'building site': Deploy directory 'build' does not exist
7:36:08 PM: Finished processing build request in 2.648088496s

hi there, can you post a screenshot of your build commands please?

Here are my scripts

"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
}

Here’s the link to my GitHub repo

I’ve been unable to get Netlify to successfully build after I push to GitHub.
(Every time I push to GitHub, I get a failed build)

So I’ve resorted to adding a manual deploy script in my package.json

{
  scripts: {
    ...,
    "deploy": "yarn build && netlify deploy --prod"
  }
}

with this netlify.toml in my repo root.

[build]	
    build = "build"

[build.environment]	
    NODE_ENV = "development"	

[context.production.environment]	
    NODE_ENV = "production"

Hi, @Fullchee. The original error is because the publish directory is set to “build”. This is handled as a subdomain relative to the base directory of the repo.

I cloned the repo and there is no subdirectory named build:

$ ls -1 reminders-frontend
README.md
netlify.toml
node_modules
package-lock.json
package.json
public
src

This is the reason for the error in the build logs above:

7:36:08 PM: No build command found, continuing to publishing
7:36:08 PM: Failing build: Failed to build site
7:36:08 PM: Failed during stage 'building site': Deploy directory 'build' does not exist

The publish directory was configured to be “build”. This directory didn’t exist and therefore caused an error.

If there are other questions about this, please let us know.

1 Like

I fixed this by having a command in my netlify.toml

[build]	
    command = "yarn build"
    build = "build"

Thank you for the help!

1 Like

Yes, all I had to do was change my out directory from .build to .dist

1 Like