Replies: 3 comments
-
✅ **Valid Answer **Your Docker environment is case-sensitive, while your local Windows/Mac filesystem is not. import ChartAllUsers from "@/components/charts/ChartAllUsers"will only work if the folder and file names match exactly:
On local, these still resolve. ✔️ Steps to Fix1. Check folder & file name casingVerify the exact file path: If the file is named something like git mv chartAllUsers.tsx ChartAllUsers.tsx(Use 2. Confirm the Next.js alias is correctYour config is correct: tsconfig.json "paths": {
"@/*": ["./src/*"]
}next.config.ts config.resolve.alias['@'] = path.join(__dirname, 'src');No changes needed here. 3. Rebuild inside DockerAfter fixing casing: docker compose build
docker compose upNow Docker (Linux) will correctly resolve the module. ✔️ Why it happenedLocal dev (Windows/macOS) = case-insensitive filesystem So imports must match exactly, including capitalization. |
Beta Was this translation helpful? Give feedback.
-
|
This is the real solution The error Module not found: Can't resolve '@/components/charts/ChartAllUsers' is caused by case sensitivity differences between your local system and Docker Linux. Steps to fix
import ChartAllUsers from "@/components/charts/ChartAllUsers"; Ensure the file is named exactly ChartAllUsers.tsx, not chartAllUsers.tsx or Chartallusers.tsx.
This ensures Git tracks the case change.
"paths": { "@/": ["./src/"] } In next.config.ts: config.resolve.alias['@'] = path.join(__dirname, 'src'); No further changes needed if already set.
Summary This ensures your modules resolve correctly in both local and Docker environments. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, Sorry for the apparently generated answers that didn't even bother to check your repository 😢 - and quickly see that the casing is all correct. What I see, is that your Which AFAIK, prevents the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
got this error after docker dploy and return to local:
Module not found: Can't resolve '@/components/charts/ChartAllUsers'
./src/app/(frontend)/(users)/home/admin/page.tsx (3:1)
Module not found: Can't resolve '@/components/charts/ChartAllUsers'
1 | import Image from "next/image"
2 | /* components */
Import map: aliased to relative './src/components/charts/ChartAllUsers' inside of [project]/
Additional information
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions