Next.js Discord

Discord Forum

Monorepo deployment issue on Vercel – shared package @repo/ui not resolved

Unanswered
Madeiran sardinella posted this in #help-forum
Open in Discord
Madeiran sardinellaOP
I’m trying to deploy our homepage repo (apps/nd-web-home) to Vercel.
• Locally: the build works fine.
• On Vercel: the deploy fails with Module not found: Can't resolve '@repo/ui'.

Our setup:
• /packages/ui → shared component repo (@repo/ui) used across apps.
• /apps/nd-web-home → homepage app that imports from @repo/ui.

My Vercel build command looks like this:

"export:dev:homepage:vercel": "yarn turbo run build --scope=@repo/ui --include-dependencies --no-deps && turbo run export export:dev --scope=nd-web-home --include-dependencies --no-deps"
When Vercel runs the build, @repo/ui is built successfully (using tsup) and outputs to dist/.
But when Next.js builds nd-web-home, it fails to resolve @repo/ui.

Here’s the relevant part of the Vercel error log:

16:21:45.863 nd-web-home:export:dev: Failed to compile. ./src/components/app/brands/brands-profile-page.tsx Module not found: Can't resolve '@repo/ui' ./src/components/app/profilepage/profile-page.tsx Module not found: Can't resolve '@repo/ui' ./src/components/homepage/components/landing/landing.tsx Module not found: Can't resolve '@repo/ui' ./src/components/shared/contact-us-section.tsx Module not found: Can't resolve '@repo/ui' ./src/layouts/homepage-layout/nav/MobileProfileMenu.tsx Module not found: Can't resolve '@repo/ui'
Build failed because of webpack errors

log shows @repo/ui builds fine with cache hit + successful tsup output, but Next.js still cannot resolve the package during the homepage build.

7 Replies

Madeiran sardinellaOP
Can anyone help?
Pacific sand lance
u shared no code to provide any meanigful solution
include package in package.json, transpilePackages and tsconfig
Madeiran sardinellaOP
package/ui - tsconfig.json
{
  "extends": "@repo/typescript-config/react-library.json",
  "compilerOptions": {
    "lib": ["dom", "ES2015"],
    "types": ["node"],
    "paths": {
      "@/*": ["./src/*"]
    },
    "module": "esnext"
  },
  "include": [".", ".eslintrc.cjs"],
  "exclude": ["dist", "build", "node_modules"]
}

package/ui - tsup.config.ts
import { defineConfig, type Options } from 'tsup';
import svgrPlugin from 'esbuild-plugin-svgr';

export default defineConfig((options: Options) => ({
  banner: {
    js: "'use client'",
  },

  esbuildPlugins: [svgrPlugin()],

  ...options,
}));
apps/nd-web-home - tsconfig.json
{
  "extends": "@repo/typescript-config/nextjs.json",
  "compilerOptions": {
    "plugins": [
      {
        "name": "next"
      }
    ],

    "paths": {
      "@/*": ["./src/*"]
    },

    "incremental": true
  },
  "include": [
    "next-env.d.ts",
    "next.config.js",
    "**/*.ts",
    "**/*.tsx",
    ".next/types/**/*.ts",
    ".eslintrc.js"
  ],
  "exclude": ["node_modules", "out"]
}
@Pacific sand lance