"Build not found" React.js

Hello,

This is the second (MERN) ReactJs project that I am trying to deploy. The first one worked like a charm but I’m having issues with the second one. I’m getting a “Failed during stage ‘building site’: Deploy directory ‘build’ does not exist”. I added a netlify.toml file that has:

[[redirects]]   
from = "/*"   
to = "/index.html"   
status = 200 

[build]	
    command = "npm run-script build"
    build = "build"

Netlify site name: blissful-fermi-fe94ed

Here is my deploy log:
7:18:26 PM: Build ready to start
7:18:28 PM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
7:18:28 PM: build-image tag: v3.4.1
7:18:28 PM: buildbot version: fcbc7a79f7372e5995cf02954ef19fc48d20c871
7:18:28 PM: Fetching cached dependencies
7:18:28 PM: Failed to fetch cache, continuing with build
7:18:28 PM: Starting to prepare the repo for build
7:18:29 PM: No cached dependencies found. Cloning fresh repo
7:18:29 PM: git clone GitHub - denzgrant/React-Google-Books
7:18:30 PM: Preparing Git Reference refs/heads/master
7:18:31 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: ‘build’ versus ‘build/’ in the Netlify UI
7:18:31 PM: Different build command detected, going to use the one specified in the Netlify configuration file: ‘npm run-script build’ versus ‘npm run build’ in the Netlify UI
7:18:31 PM: Starting build script
7:18:31 PM: Installing dependencies
7:18:31 PM: Python version set to 2.7
7:18:33 PM: v12.18.0 is already installed.
7:18:33 PM: Now using node v12.18.0 (npm v6.14.4)
7:18:33 PM: Started restoring cached build plugins
7:18:33 PM: Finished restoring cached build plugins
7:18:33 PM: Attempting ruby version 2.7.1, read from environment
7:18:35 PM: Using ruby version 2.7.1
7:18:35 PM: Using PHP version 5.6
7:18:35 PM: 5.2 is already installed.
7:18:35 PM: Using Swift version 5.2
7:18:35 PM: Started restoring cached node modules
7:18:35 PM: Finished restoring cached node modules
7:18:35 PM: Installing NPM modules using NPM version 6.14.4
7:18:44 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
7:18:44 PM: > node scripts/install.js
7:18:44 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
7:18:47 PM: Download complete
7:18:47 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
7:18:47 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
7:18:47 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
7:18:47 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
7:18:47 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
7:18:47 PM: > node scripts/build.js
7:18:48 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
7:18:48 PM: Testing binary
7:18:48 PM: Binary is fine
7:18:48 PM: > nodemon@1.19.4 postinstall /opt/build/repo/node_modules/nodemon
7:18:48 PM: > node bin/postinstall || exit 0
7:18:48 PM: Love nodemon? You can now support the project via the open collective:
7:18:48 PM: > Contribute to nodemon - Open Collective
7:18:48 PM: > mern@1.0.0 install /opt/build/repo
7:18:48 PM: > cd client && npm install
7:19:20 PM: > core-js@2.6.11 postinstall /opt/build/repo/client/node_modules/core-js
7:19:20 PM: > node -e “try{require(‘./postinstall’)}catch(e){}”
7:19:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/watchpack/node_modules/fsevents):
7:19:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
7:19:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
7:19:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
7:19:22 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/chokidar/node_modules/fsevents):
7:19:22 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
7:19:22 PM: added 1910 packages from 687 contributors and audited 1980 packages in 34.058s
7:19:24 PM: 33 packages are looking for funding
7:19:24 PM: run npm fund for details
7:19:24 PM: found 91 vulnerabilities (82 low, 2 moderate, 7 high)
7:19:24 PM: run npm audit fix to fix them, or npm audit for details
7:19:24 PM: npm WARN mern@1.0.0 No description
7:19:24 PM: npm WARN mern@1.0.0 No repository field.
7:19:24 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/fsevents):
7:19:24 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
7:19:24 PM: added 513 packages from 286 contributors and audited 516 packages in 48.079s
7:19:24 PM: 7 packages are looking for funding
7:19:24 PM: run npm fund for details
7:19:24 PM: found 2 vulnerabilities (1 low, 1 high)
7:19:24 PM: run npm audit fix to fix them, or npm audit for details
7:19:24 PM: NPM modules installed
7:19:25 PM: Started restoring cached go cache
7:19:25 PM: Finished restoring cached go cache
7:19:25 PM: go version go1.14.4 linux/amd64
7:19:25 PM: go version go1.14.4 linux/amd64
7:19:25 PM: Installing missing commands
7:19:25 PM: Verify run directory
7:19:26 PM: ​
7:19:26 PM: ┌─────────────────────────────┐
7:19:26 PM: │ Netlify Build │
7:19:26 PM: └─────────────────────────────┘
7:19:26 PM: ​
7:19:26 PM: ❯ Version
7:19:26 PM: @netlify/build 3.3.0
7:19:26 PM: ​
7:19:26 PM: ❯ Flags
7:19:26 PM: deployId: 5f45c6728106ae0007b06f62
7:19:26 PM: mode: buildbot
7:19:26 PM: ​
7:19:26 PM: ❯ Current directory
7:19:26 PM: /opt/build/repo
7:19:26 PM: ​
7:19:26 PM: ❯ Config file
7:19:26 PM: /opt/build/repo/netlify.toml
7:19:26 PM: ​
7:19:26 PM: ❯ Context
7:19:26 PM: production
7:19:26 PM: ​
7:19:26 PM: ┌────────────────────────────────────┐
7:19:26 PM: │ 1. build.command from netlify.toml │
7:19:26 PM: └────────────────────────────────────┘
7:19:26 PM: ​
7:19:26 PM: $ npm run-script build
7:19:26 PM: > mern@1.0.0 build /opt/build/repo
7:19:26 PM: > cd client && npm run build
7:19:26 PM: > mern@0.1.0 build /opt/build/repo/client
7:19:26 PM: > react-scripts build
7:19:28 PM: Creating an optimized production build…
7:19:40 PM: Compiled successfully.
7:19:40 PM:
7:19:40 PM: File sizes after gzip:
7:19:40 PM: 51.77 KB build/static/js/2.2dde2e74.chunk.js
7:19:40 PM: 2.42 KB (+19 B) build/static/js/main.25370fb4.chunk.js
7:19:40 PM: 763 B build/static/js/runtime~main.d653cc00.js
7:19:40 PM: 344 B build/static/css/main.1930c81d.chunk.css
7:19:40 PM: The project was built assuming it is hosted at ./.
7:19:40 PM: You can control this with the homepage field in your package.json.
7:19:40 PM: The build folder is ready to be deployed.
7:19:40 PM: Find out more about deployment here:
7:19:40 PM: create-react-app/README.md at main · facebook/create-react-app · GitHub
7:19:40 PM: ​
7:19:40 PM: (build.command completed in 14s)
7:19:40 PM: ​
7:19:40 PM: ┌─────────────────────────────┐
7:19:40 PM: │ Netlify Build Complete │
7:19:40 PM: └─────────────────────────────┘
7:19:40 PM: ​
7:19:40 PM: (Netlify Build completed in 14s)
7:19:40 PM: Caching artifacts
7:19:40 PM: Started saving node modules
7:19:40 PM: Finished saving node modules
7:19:40 PM: Started saving build plugins
7:19:40 PM: Finished saving build plugins
7:19:40 PM: Started saving pip cache
7:19:40 PM: Finished saving pip cache
7:19:40 PM: Started saving emacs cask dependencies
7:19:40 PM: Finished saving emacs cask dependencies
7:19:40 PM: Started saving maven dependencies
7:19:40 PM: Finished saving maven dependencies
7:19:40 PM: Started saving boot dependencies
7:19:40 PM: Finished saving boot dependencies
7:19:40 PM: Started saving go dependencies
7:19:40 PM: Finished saving go dependencies
7:19:44 PM: Build script success
7:19:44 PM: Failing build: Failed to build site
7:19:44 PM: Failed during stage ‘building site’: Deploy directory ‘build’ does not exist
7:19:44 PM: Finished processing build request in 1m15.352025027s

Hi, @denzcodergrant, please note that I was able to answer this so quickly only because the site’s repo is public. This allowed me to test and see what is happening.

The issue itself is stated in the build logs:

7:19:44 PM: Failed during stage ‘building site’: Deploy directory ‘build’ does not exist

I cloned the repo, ran npm install, and then ran npm run build. Below is a listing of all files and directories in the base of the repo once that is done:

$ ls -1
client
controllers
models
netlify.toml
node_modules
package-lock.json
package.json
routes
server.js

There is no directory named build. The deploy directory is actually client/build not build alone. Please change this line in netlify.toml from this:

    build = "build"

To this:

    build = "client/build"

If that is done it should deploy correctly. If this doesn’t work or if there are questions, please let us know.

I can’t believe I missed that. It worked. Thank you Luke!!

2 Likes