Build Site Failing for Monorepo

I recently tried migrating my sites to a monorepo setup (after reading about Netlify’s new support for monorepo deploys), but noticed something very strange, for one of the sites, I have the following setup:

Base directory: packages/<my-site>
Build command: npm run build:prod
Publish directory: packages/<my-site>/dist 

The folder structures look fine, but during deploy it would fail with: failed during stage 'building site': Deploy directory 'dist' does not exist

However, the deploy does work if I change publish directory to the following:

From this it seems like the problem is due to Netlify not picking up the Base directory correctly? Curious why is this happening (another site under the same repo works fine without the hack) and if there is a way to fix this, to avoid this hack (adding base dir twice)?


Hi, @gum, and welcome to our Netlify community site.

Would you please send us a link to the affected site at Netlify? I’ve made sure you can send a private message (PM), if you don’t want to send it publicly.

Thanks @luke ! I’ve PM’ed you the site as well as a recent deploy that replicates this issue.

I’ve also tried a few other things:

  • Creating a new test site & tried to deploy the same mono repo with the same base/publish directory settings

The new test site was able to deploy with the exact same setting (in the deploy log it’d say deployed to <base>/<path>/dist instead of just dist)

My guess is because my original site was created before mono repo / base dir support, something got stuck or cached so adding a base directory doesn’t actually cause it to be used during deploy? (I’ve tried “Clear cache and deploy site”, and also re-linked the git repo + connecting to a brand new repo).

So technically I could just create a new site & move all my configs/setup over, but that’s less than ideal and I think I’d also lose all the form/messages as well as old analytics?

Anyhoo thanks for looking into it!

Hi, @gum. For sites created before the monorepo support was launched, the usual solution is to re-link the same git repo again. This alone will (or at least should be) all that is required to enable the monorepo support for a site.

If the “re-link existing repo” solution doesn’t fix missing monorepo support for any of your other Netlify sites, please let us know.

Hi @luke, thanks for getting back, I did indeed re-link the repo several times to no avail.

For now I’ve switched it back to the old non-mono repo to unblock site development, however, it’d be great to know why re-linking isn’t working as I’d love to make use of Netlify’s mono repo support. Appreciate all the help so far.

Hi @gum,

I checked your site and it does have the new monorepo support enabled. In your initial post, you mentioned that your publish directory was packages/<my-site>/dist. One thing to note is that when this feature is enabled, the expected value for base and publish directories are:

Base directory: packages/<my-site>
Publish directory: dist/

Notice that the publish directory is relative to the base directory. Let me know if that works for you.

Hi @Dennis @luke thanks for getting back, I see how my original post may have been confusing when I mentioned my publish directory was packages/<my-site>/, I simply included that part because that was a UI label Netlify is displaying (I’m guessing it’s there as a label to make things more user-friendly?)

I have attached screenshots below to illustrate exactly what I’m encountering (after re-linking my github repo, with both deploys w/ cache cleared):


Deploy failure msg:

Case 2: WORKS (but something is not right)

Deploy success!

Notice how in Case 2 where it works, I essentially had to enter the same path for BOTH base directory as well as part of the publish directory (so it was essentially packages/<my-site>/packages/<my-site>/dist)

As mentioned in my previous post, I experimented with a few different setups, and noticed that while this issue happens for my current site (that was created before monorepo feature became a thing), using the same settings (from Case 1) for a new Netlify site/project work just fine.

My intuition is that despite this should be working after a github repo re-link, there is probably some cached/old setting somewhere (or because of a particular state that my site/project is in) that is causing the base directory input to not be prepended correctly during deploy (hence the console output from the failed deploy)

So technically a work around would be to simply delete this project and create a new one and get on with my monorepo happily ever after… but as mentioned in my previous post, that would probably mean 1) I’d have to setup all the domain / contact / etc. settings for the new project and 2) I’d probably loose all Analytics data as well as contact data from the old site, which is less than ideal.

I could also just always include the full path in the Publish directory input, but that just feels like a hacky workaround…

Let me know if this clears up the issue I’m encountering. For now I’ve basically gone back to my old multi-repo setup until further update.

Again, thanks for looking into this, and happy holidays!

Are you using the Trusty build-image? Can you try changing the build-image to Xenial instead and see if things work better?

Hi @Dennis, changing the image to Xenial did indeed resolve the issue for me, thanks a bunch!