I made a nextjs 14.1.4
project on my local windows machine which I can build with npm run build
without any problem, but
when I try to build on my production server: Ubuntu 22.04.3 LTS with npm run build
I get the following error:
./src/pages/about.tsx:7:20
Type error: Cannot find module '@/components/Layout' or its corresponding type declarations.
the code snippet from the component looks as:
import TestimonialPage from "@/components/about/TestimonialPage"
import Layout from "@/components/Layout"
import BaseButton from "@/components/base/BaseButton"
which is just a normal import statement.
I tried to change in my tsconfig.json
the line with "moduleResolution": "bundler"
with "moduleResolution": "node"
but without any effect.
Also tried to change the "paths"
:
"paths": {
"@/*": ["./src/*"]
}
to
"paths": {
"@/*": ["src/*"]
}
but without success.
What else can I do?
2
Answers
Verify that your tsconfig.json file is correctly configured to handle module resolution
Some OS’s are case-sensitive when importing files. Make sure to double-check if the right path is
or