如何修复“未找到”模块。部署nextJS应用程序的错误

发布于 2025-01-30 04:08:04 字数 1524 浏览 3 评论 0原文

我正在尝试部署我的nextjs应用程序以netlify,但它一直显示错误
找不到模块:无法解析'../components/home/home'in'/opt/opt/build/repo/pem' in Build Log。
但是本地构建命令没有导致任何错误。

我在Netlify中的构建设置是:
基本目录 未设置
构建命令 npm运行构建
发布目录 .next
构建 活动

部署日志包含此错误消息

7:06:59 AM: ./pages/index.js
7:06:59 AM: Module not found: Can't resolve '../components/home/home' in '/opt/build/repo/pages'
7:06:59 AM: > Build failed because of webpack errors
7:06:59 AM: ​
7:06:59 AM: ────────────────────────────────────────────────────────────────
7:06:59 AM:   "build.command" failed                                        
7:06:59 AM: ────────────────────────────────────────────────────────────────
7:06:59 AM: ​
7:06:59 AM:   Error message
7:06:59 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
7:06:59 AM: ​
7:06:59 AM:   Error location
7:06:59 AM:   In Build command from Netlify app:
7:06:59 AM:   npm run build
7:06:59 AM: ​
7:06:59 AM:   Resolved config
7:06:59 AM:   build:
7:06:59 AM:     command: npm run build
7:06:59 AM:     commandOrigin: ui
7:06:59 AM:     environment:
7:06:59 AM:       - NEXT_PRIVATE_TARGET
7:06:59 AM:     publish: /opt/build/repo/.next
7:06:59 AM:     publishOrigin: ui
7:06:59 AM:   plugins:
7:06:59 AM:     - inputs: {}
7:06:59 AM:       origin: ui
7:06:59 AM:       package: '@netlify/plugin-nextjs'
7:06:59 AM: Caching artifacts

I'm trying to deploy my NextJS App to Netlify but it keeps showing the error
Module not found: Can't resolve '../components/home/home' in '/opt/build/repo/pages'in the build log.
But locally the build command didn't result in any errors.

My build settings in Netlify are:
Base directory Not set
Build command npm run build
Publish directory .next
Builds Active

Deploy log contains this error message

7:06:59 AM: ./pages/index.js
7:06:59 AM: Module not found: Can't resolve '../components/home/home' in '/opt/build/repo/pages'
7:06:59 AM: > Build failed because of webpack errors
7:06:59 AM: ​
7:06:59 AM: ────────────────────────────────────────────────────────────────
7:06:59 AM:   "build.command" failed                                        
7:06:59 AM: ────────────────────────────────────────────────────────────────
7:06:59 AM: ​
7:06:59 AM:   Error message
7:06:59 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
7:06:59 AM: ​
7:06:59 AM:   Error location
7:06:59 AM:   In Build command from Netlify app:
7:06:59 AM:   npm run build
7:06:59 AM: ​
7:06:59 AM:   Resolved config
7:06:59 AM:   build:
7:06:59 AM:     command: npm run build
7:06:59 AM:     commandOrigin: ui
7:06:59 AM:     environment:
7:06:59 AM:       - NEXT_PRIVATE_TARGET
7:06:59 AM:     publish: /opt/build/repo/.next
7:06:59 AM:     publishOrigin: ui
7:06:59 AM:   plugins:
7:06:59 AM:     - inputs: {}
7:06:59 AM:       origin: ui
7:06:59 AM:       package: '@netlify/plugin-nextjs'
7:06:59 AM: Caching artifacts

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

厌味 2025-02-06 04:08:04

我找到了解决我自己问题的解决方案。
它与Windows Case不敏感有关,而NetLify使用Linux服务器!
因此,我不得不重命名所有下降的命名组件中的大写组件,并且起作用。

这些文章对我有所帮助。
https://github.com/github.com/vercel/next.js/next.js/discussions/16179
更改git中的文件名的资本化

我希望它将对未来的人有帮助。

I have found the solution to my own problem.
It's related to Windows case insensitive whereas Netlify uses Linux servers which are!
So, I had to rename all my lowercased named components to uppercase and it worked.

These articles have helped me.
https://github.com/vercel/next.js/discussions/16179
Changing capitalization of filenames in Git

I hope it will help someone in the future.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文