Reputation: 61
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
Upvotes: 2
Views: 2172
Reputation: 61
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.
Upvotes: 4