Hi Vercel Community,
I’m facing an issue with deploying an Nx-based monorepo on Vercel, and I could use some help.
Earlier when this application was standalone, everything worked fine. Now, I have moved it to mono-repo.
All my scripts are working fine, I’m able to create a successful local build, but it’s failing with vercel deployment.
Project Structure:
apps/pay-platform
apps/storybook
packages/fe-utils
packages/skuad-ui
packages/fe-core
The build output is located in the dist
folder with respective app/library folder names. My project uses a single package.json
at the root level, and each app/library has its own project.json
, where their respective commands are defined. For simplicity, I have added a few scripts inside the root package.json
like this:
"scripts": {
"clean": "pnpm recursive exec -- rm -rf node_modules || true && rm -rf dist && rm -rf build && rm -rf */*/dist || true && rm -rf */*/build || true",
"pay-platform:gql-codegen": "nx run pay-platform:gql-codegen",
"pay-platform:serve": "nx run pay-platform:serve",
"pay-platform:prettify": "nx run pay-platform:prettify",
"storybook:serve": "nx run storybook:serve",
"package-testing-app:serve": "nx run package-testing-app:serve",
"pay-platform:build": "nx run pay-platform:build",
"pay-platform:build:vercel": "pnpm pay-platform:gql-codegen && pnpm pay-platform:build",
"storybook:build": "nx run storybook:build",
"fe-core:build": "nx run fe-core:build",
"fe-utils:build": "nx run fe-utils:build",
"sk-ui:build": "nx run sk-ui:build",
"ui-components:build": "nx run ui-components:build",
"test-all": "nx run-many --all --target=test",
"lint-all": "nx run-many --all --target=lint",
"build-all": "nx run-many --all --target=build",
"reset-cache": "nx reset",
"prepare": "husky install"
}
Vercel Configuration:
My .vercel/project.json
looks like this:
{
"projectId": "qwertyuiop_qwertyuiop",
"orgId": "asdfghjkl_asdfghjkl",
"settings": {
"createdAt": 1722578989045,
"framework": "vite",
"devCommand": "pnpm dev",
"installCommand": "pnpm install",
"buildCommand": "pnpm run pay-platform:build:vercel",
"outputDirectory": "dist/apps/pay-platform",
"rootDirectory": null,
"directoryListing": false,
"nodeVersion": "20.x"
}
}
Issue:
While the build command works perfectly fine locally, it fails during deployment on Vercel with the following error:
> vercel build
Vercel CLI 35.2.3
Detected `pnpm-lock.yaml` version 6 generated by pnpm 8
Running "install" command: `pnpm install`...
Lockfile is up to date, resolution step is skipped
Already up to date
> @skuad/skuad-fe@0.0.1 prepare /Users/rishavpandey/Professional Work/Skuad/skuad-fe
> husky install
Done in 2.3s
sh: pay-platform:build:vercel: command not found
Error: Command "pay-platform:build:vercel" exited with 127
Request for Help:
I’m looking for any guidance or insights on what might be causing the command not to be found in the Vercel build environment. Any suggestions on how to configure Vercel to work seamlessly with an Nx-based monorepo would be greatly appreciated.
Thank you all in advance for your help!