I have a repo that has the backend and frontend (create-react-app) in two separate folders. For the build command, I have something like cd frontend && npm run build
and for the publish directory, I have something like frontend/build
, but this is not working.
using Netlify CLI when setting up continuous deployment for a site. Change to the subdirectory that you'd like to set as the base, then run the netlify init command. The current working directory is then specified as the base.
While it's amazing that Netlify automatically deploys websites whenever code is pushed, sometimes you need deploys to happen on a more regular interval.
The netlify. toml is a configuration file that specifies how Netlify builds and deploys your site — including redirects, branch and context-specific settings, and more.
disclaimer: I work for Netlify.
If you were to clone a new copy (no node modules installed in the project, for instance) of your project on a fresh laptop with nothing else except node and npm installed there, how would you build it? Imagine netlify's build process like that. So you're missing at least an "npm install" step in there :)
Anything else missing, like globally installed npm packages? Need to specify them in package.json
so that Netlify's build network knows to grab them for you. Ruby gems? Better have a Gemfile
in your repo!
Netlify tries to npm install
(and bundle install
) automatically for you, assuming there is a package.json
either in the root of your repository (I'm guessing yours is in frontend/
?) OR if you set the "base" parameter so that we start our build in the base directory. This is probably a good pattern for you, to set "base" to frontend
, and then set your publish directory to build
.
You can specify that base parameter in netlify.toml something like this:
[build]
base = "frontend"
Note that netlify.toml
must reside in the root of your repository.
For more details on how Netlify builds, check out the following articles:
If after some reading and experimenting, you still can't figure things out, ping the helpdesk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With