When I run the command npm run build
, my Next.js application builds successfully without any issues.
However, when I try to build it in my Dockerfile, I encounter the following problem:
#0 12.18 Type error: Cannot find module '@mui/x-date-pickers/AdapterDateFns' or its corresponding type declarations.
#0 12.18
#0 12.18 4 | import useupdateManifest from 'src/hooks/manifest/useUpdateManifest';
#0 12.18 5 | import { manifests } from 'src/types/manifest/manifests';
#0 12.18 > 6 | import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
#0 12.18 | ^
#0 12.18 7 | import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
#0 12.18 8 | import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker';#0 12.18 9 | import { branchVehicleStoreVar } from 'src/Store/branchVehicleStore';
------
failed to solve: executor failed running [/bin/sh -c npm run build]: exit code: 1
This is a list of dependencies from my package.json
file:
"dependencies": {
// List of dependencies here
},
I would greatly appreciate any assistance with this issue. Thank you in advance.
Dockerfile:
# Instructions for Dockerfile
FROM node:alpine
WORKDIR /app
COPY ./package.json .
RUN npm install --force
COPY . .
RUN npm run build
EXPOSE 8101
CMD ["npm", "run", "start" ]
Docker-compose file:
version: '3.8'
services:
frontend:
build: .
container_name: next_c
ports:
- '8101:8101'
stdin_open: true
tty: true
.dockerignore file:
/.next/
/node_modules