未找到模块:无法解析NextJS

cxfofazt  于 2023-05-06  发布在  其他
关注(0)|答案(1)|浏览(227)

我尝试在Vercel上部署Next.js网站,但出现此错误。这是一个使用GraphQL CMS创建的网站。
我已经放置了部署环境,但仍然不工作。

[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 Repo:https://github.com/rusbenmadrigal/taxes-hub
网络在本地加载良好,但我可以将其部署到Vercel中。
谢谢大家!

enyaitl3

enyaitl31#

文件夹和文件的名称不正确。我不明白它在当地是如何运作的
在许多地方,您导入from "../services";,但文件名为Services。应该是from "../Services";
components/index.js中,您有

export { default as Categories } from "./CateGories";

但文件名是Categories

相关问题