使用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
相关产品推荐
相关产品推荐

