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

Vercel部署Next.js项目遇Module not found错误,本地运行正常求助

Next.js + GraphQL CMS 部署Vercel构建失败问题

我尝试在Vercel上部署一个基于GraphQL CMS构建的Next.js网站,但出现构建失败问题。已配置部署环境变量,但问题仍未解决。该网站在本地可正常加载,却无法部署到Vercel。以下是构建日志详情:

[18:57:48.058] Running build in San Francisco, USA (West) – sfo1
[18:57:48.122] Cloning github.com/rusbenmadrigal/taxes-hub (Branch: main, Commit: d77d23b)
[18:57:48.130] Skipping build cache, deployment was triggered without cache.
[18:57:48.917] Cloning completed: 794.466ms
[18:57:49.111] Running "vercel build"
[18:57:49.687] Vercel CLI 29.0.1
[18:57:50.002] Installing dependencies...
[18:58:01.885] 
[18:58:01.885] added 344 packages in 11s
[18:58:01.885] 
[18:58:01.886] 122 packages are looking for funding
[18:58:01.886]   run `npm fund` for details
[18:58:01.908] Detected Next.js version: 13.3.2-canary.14
[18:58:01.912] Detected `package-lock.json` generated by npm 7+...
[18:58:01.913] Running "npm run build"
[18:58:02.303] 
[18:58:02.304] > blog@0.1.0 build
[18:58:02.304] > next build
[18:58:02.304] 
[18:58:02.688] info  - Loaded env from /vercel/path0/.env
[18:58:02.874] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[18:58:02.874] This information is used to shape Next.js' roadmap and prioritize features.
[18:58:02.875] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[18:58:02.875] https://nextjs.org/telemetry
[18:58:02.875] 
[18:58:03.035] info  - Linting and checking validity of types...
[18:58:05.064] 
[18:58:05.064] ./components/PostCard.jsx
[18:58:05.065] 10:11  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
[18:58:05.065] 23:11  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
[18:58:05.065] 
[18:58:05.065] ./components/PostDetail.jsx
[18:58:05.068] 50:11  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
[18:58:05.068] 67:11  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
[18:58:05.068] 76:15  Warning: Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element  @next/next/no-img-element
[18:58:05.069] info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
[18:58:05.083] info  - Creating an optimized production build...
[18:58:08.703] Failed to compile.
[18:58:08.703] 
[18:58:08.703] ./components/Categories.jsx
[18:58:08.703] Module not found: Can't resolve '../services'
[18:58:08.703] 
[18:58:08.704] https://nextjs.org/docs/messages/module-not-found
[18:58:08.704] 
[18:58:08.704] Import trace for requested module:
[18:58:08.704] ./components/index.js
[18:58:08.704] ./pages/post/[slug].js
[18:58:08.704] 
[18:58:08.704] ./components/Header.jsx
[18:58:08.705] Module not found: Can't resolve '../services'
[18:58:08.705] 
[18:58:08.705] https://nextjs.org/docs/messages/module-not-found
[18:58:08.705] 
[18:58:08.705] Import trace for requested module:
[18:58:08.705] ./components/index.js
[18:58:08.705] ./pages/post/[slug].js
[18:58:08.705] 
[18:58:08.705] ./components/PostWidget.jsx
[18:58:08.705] Module not found: Can't resolve '../services'
[18:58:08.705] 
[18:58:08.706] https://nextjs.org/docs/messages/module-not-found
[18:58:08.706] 
[18:58:08.706] Import trace for requested module:
[18:58:08.706] ./components/index.js
[18:58:08.706] ./pages/post/[slug].js
[18:58:08.706] 
[18:58:08.706] ./pages/category/[slug].js
[18:58:08.706] Module not found: Can't resolve '../../services'
[18:58:08.706] 
[18:58:08.706] https://nextjs.org/docs/messages/module-not-found
[18:58:08.707] 
[18:58:08.707] ./pages/index.js
[18:58:08.707] Module not found: Can't resolve '../services'
[18:58:08.708] 
[18:58:08.709] https://nextjs.org/docs/messages/module-not-found
[18:58:08.709] 
[18:58:08.709] 
[18:58:08.709] > Build failed because of webpack errors
[18:58:08.746] Error: Command "npm run build" exited with 1
[18:58:09.108] Deployment completed
[18:58:09.069] BUILD_UTILS_SPAWN_1: Command "npm run build" exited with 1

GitHub仓库:rusbenmadrigal/taxes-hub

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.23 02:24:58