Failed to deploy functions if project is located in subdirectory (with minimal example to reproduce)

Edited: solved, see post

Hi,
TL;DR - This issue only happens when project root directory (and its corresponding vercel.json) is located in a subfolder. Vercel fails to properly find api/index.js and deploy it into functions.
I’ve tried to search through community and wondering why few people has mentioned this issue? Where am I doing wrong?

Here is the minimal example for you to reproduce the issue:
(Project Information is provided below)

From the attached screenshot you can clearly see, one deployment has functions while the other doesn’t.
I’ve also downloaded the api/index.js of each deployment and found that their contents were identical. So the build process shouldn’t have anything wrong.


Succesful Deployment URL: https://express-vercel-2tp8rntjg-hmpthzs-projects.vercel.app
Failed Deployment URL: https://express-vercel-8sam9n51l-hmpthzs-projects.vercel.app
Environment (local, preview, production): Doesn't matter
Project Framework:
Build Settings:
  Framework Preset: Other
  Build Command (if not default): pnpm run -F server build && node postinstall.cjs
  Output Directory (if not default): dist
  Install Command (if not default): pnpm -F server install
Node/Runtime Version:
Package Manager: pnpm (I'm using its workspace feature, but I don't think this is the problem
Relevant Packages:

I created a github issue. We can also discuss it there.

Just found out the real issue here, close the discussion.

1 Like

Thanks, @hmpthz! Glad you found a solution. :pray:

Hi @pawlean , thanks for your reply. Although my problem has solved, there are still monorepo-related issues circulating around.

Just to name two of them that I found out, which can be easily reproduced:

  1. When vercel compiles functions, it can only get dependencies from root directory. If deps (like express.js) are installed in subprojects, it fails to find those modules. (I’m using pnpm workspace, not sure other package managers are the same)
  2. According to docs, " .vercelignore file should be placed in the root directory of your project". But in reality, it should be place at the root directory of repository, even if you configure the project to be in a subdirectory.

I’ve seen a lot of monorepo-related issues on github. I suppose they’re generally considered as low priority by vercel team. I just hope they can gain more attention in the future.

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