You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用pnpm+Monorepo部署Next.js到Vercel遇模块缺失Bug求助

Monorepo下Next.js博客部署Vercel出现Cannot find module 'next/dist/server/next-server.js'问题

遇到了某GitHub讨论中的同款问题,无法定位原因。将Monorepo架构下开发的博客站点部署到Vercel时,出现Cannot find module 'next/dist/server/next-server.js'错误,具体情况如下:

  • 开发模式运行正常
  • 本地构建后使用next start启动完全正常
  • 部署到Vercel时触发上述错误,且仅博客页面存在问题,站点其他页面均可正常工作

Vercel CLI版本

❯ ./node_modules/.bin/vercel version
Vercel CLI 33.2.0

部署方式(在Monorepo根目录执行)

echo deploying ... \
&& pnpm --filter app-site vercel:build \
&& pnpm --filter app-site vercel:deploy \

./apps/app-site/package.json相关配置

...
    "vercel:build": "vercel build",
    "vercel:deploy": "vercel deploy --prebuilt"

目录结构

❯ tree -d -L 2 -I node_modules 
.
├── apps
│   ├── app-dash
│   ├── app-draw
│   ├── app-pres
│   └── app-site
├── bldz
├── cue.mod
├── packages
│   ├── config-eslint
│   ├── config-tailwind-js
│   ├── config-tailwind-ts
│   ├── config-typescript
│   ├── lib-auth
│   ├── lib-r3f-demos
│   ├── lib-r3f-scene
│   └── lib-react-ui

内容的提问来源于stack exchange,提问作者Ymo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 12:12:34