Next.js Discord

Discord Forum

Preview deploys to Vercel from a monorepo via the CLI

Answered
joostschuur posted this in #help-forum
Open in Discord
Is it possible to do a preview deploy via the vercel command if I'm using a monorepo with a custom root directory defined in the Vercel settings?

I have an Astro site in apps/site and if I run vercel (or vercel apps/site) from the monorepo root (or apps/site), I get a build error:

Error: The specified Root Directory "apps/site" does not exist. Please update your Project Settings.
Answered by fuma
You can use the vercel link command to select a specific workspace: https://vercel.com/docs/concepts/monorepos#using-monorepos-with-vercel-cli
View full answer

21 Replies

The site deploys fine via the git integration and I don't have a vercel.json file (the root dir setting is done via the Vercel admin panel).
You can use the vercel link command to select a specific workspace: https://vercel.com/docs/concepts/monorepos#using-monorepos-with-vercel-cli
Answer
@fuma You can use the `vercel link` command to select a specific workspace: https://vercel.com/docs/concepts/monorepos#using-monorepos-with-vercel-cli
Ah, I thought if it was smart enough to trigger the build attempt, it was already linked.

However, that still didn't seem to work, and I'm still getting the same error.

FWIW, I ran the link command in the monorepo root and not the apps/site project root.
Remove the cwd option, it must be ran in the root directory of your monorepo
Spectacled bear
Hello can I ask onething
Hmm please open another thread
@fuma Hmm please open another thread
Spectacled bear
It just small question no need to create thread
Can I ask
Will check a your suggestion shortly, hotfixing something else
@Spectacled bear Can I ask
Sure if it’s related to the question
https://dontasktoask.com/ (but in a new thread if it's not relate dot this deploy issue)
@fuma Sure if it’s related to the question
Spectacled bear
What is major difference between app and page directory. Anyone explain me.
Well it’s entirely different thing and irrelevant to this thread, please consider asking it in another thread
@Spectacled bear What is major difference between app and page directory. Anyone explain me.
You already posted this in general please don’t repost
Then open a different thread
Only ask questions related to the original question here
@joulev Then open a different thread
Spectacled bear
Done
@Spectacled bear What is major difference between app and page directory. Anyone explain me.
You can start here, but it's a very broad question, and please follow up outside of this thread https://blog.logrocket.com/next-js-13-app-directory/
Spectacled bear
Thanks
@fuma Remove the cwd option, it must be ran in the root directory of your monorepo
That worked, thanks for the quick help.

Initially, when it said ? Set up “~/Code/Playmob/greatproject.gg”? [Y/n] y, I thought that was not correct, so I added the --cwd option, but of course, it needs the whole root, or apps/site wouldn't be correct.

Brain misfired.