"Build folder build does not exist" when deploying react app

I originally tried deploying with just the script “yarn”, but this was not working. I was getting the error “react-scripts not found”.

I instead resorted to using “yarn; yarn build”, and the previous error went away. However, another error came about.

“Build folder build does not exist”

I don’t understand how the build folder build doesn’t exist. “yarn build” was just run. When I run “yarn build” locally, it creates the build folder called build. I set my publish directory to “src/build”, just as the Render docs suggest.

1 Like

HI Adam,

Thanks for reaching out.

It does seem to point to your build path is incorrect, as the error shows. Is all your code in src, e.g. the package.json also? At a guess I would think the build folder is being created in the root of the project. I’d try removing any “Root Directory” from your service settings.

As an aside, dependencies are installed automatically on Static Sites, so your Build Command could likely just be yarn build.

Kind regards

Alan

Nov. 20 07:36:38 PM ==> Cloning from GitHub - richardstuart007/quizclient021render
Nov. 20 07:36:39 PM ==> Checking out commit ece2991b79c038fd103167409c98d55370bfa8e8 in branch main
Nov. 20 07:36:41 PM ==> Downloading cache…
Nov. 20 07:36:50 PM ==> Transferred 3.1KB in 7s. Extraction took 0s.
Nov. 20 07:36:51 PM ==> Running build command ‘npm run build’…
Nov. 20 07:36:51 PM
Nov. 20 07:36:51 PM > quizclient021render@1.21.1 build /opt/render/project/src
Nov. 20 07:36:51 PM > react-scripts build
Nov. 20 07:36:51 PM
Nov. 20 07:36:51 PM sh: 1: react-scripts: not found
Nov. 20 07:36:51 PM npm ERR! code ELIFECYCLE
Nov. 20 07:36:51 PM npm ERR! syscall spawn
Nov. 20 07:36:51 PM npm ERR! file sh
Nov. 20 07:36:51 PM npm ERR! errno ENOENT
Nov. 20 07:36:51 PM npm ERR! quizclient021render@1.21.1 build: react-scripts build
Nov. 20 07:36:51 PM npm ERR! spawn ENOENT
Nov. 20 07:36:51 PM npm ERR!
Nov. 20 07:36:51 PM npm ERR! Failed at the quizclient021render@1.21.1 build script.
Nov. 20 07:36:51 PM npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Nov. 20 07:36:51 PM
Nov. 20 07:36:51 PM npm ERR! A complete log of this run can be found in:
Nov. 20 07:36:51 PM npm ERR! /opt/render/.cache/_logs/2022-11-20T06_36_51_922Z-debug.log
Nov. 20 07:36:51 PM ==> Build failed :disappointed:
Nov. 20 07:36:51 PM ==> Generating container image from build. This may take a few minutes…

I get the same error. The package.json is in the top directory.
Richard

Hi Richard,

It seems like you’ve also opened a ticket, so it’ll be best to keep the conversation in one place.

However, the above issue looks like a Web Service where you weren’t installing dependencies in the Build Command. npm install; npm run build

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.