When I try to run next build in developpement everything works perfectly.
However in production, I always have my module imported with ts path aliases not found
Here is my:
{
"compilerOptions": {
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"noEmit": false,
"noEmitOnError": false,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"target": "esnext",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
],
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
The following docker file:
FROM node
WORKDIR /workspace/frontend
ENV NODE_ENV=production
COPY package.json yarn.lock /workspace/frontend/
RUN yarn install
COPY . /workspace/frontend/
# Copy .env.production to .env.local as next read only this file
COPY .env.production /workspace/frontend/.env.local
RUN yarn build
CMD [ "sleep", "infinity" ]
yarn build
fails and raises Module not found: Can't resolve '@/components/Buttons/OverlayButtons'
.
I use app folder structure without src
folder et my component folder is in the root folder.
My version is NextJS 14.2.3.
I have already tried multiple solutions:
- Next.JS v13 in Docker does not respect path alias but works locally
New contributor
Guix is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.