找不到模块:无法解析 Docker 实现中"/client/node_modules/@mui/icons-material"中的"react/jsx-runtime"



"每当我构建并开始运行我的码头化react应用程序时,它都会不断给出标题中提到的错误。尽管我在Dockerfile中单独给出了软件包安装命令,但仍然会收到相同的错误。我还安装了包jsx运行时,但没有结果。请任何能给我指路的人">

FROM node:16-alpine
# set the working directory
WORKDIR /client
# add `/app/node_modules/.bin` to $PATH
ENV PATH /client/node_modules/.bin:$PATH

# install app dependencies
COPY package.json ./
COPY package-lock.json ./
RUN npm install --force
RUN npm install -g nodemon
RUN npm install --save ra-data-json-server --force
RUN npm install @material-ui/core --force
RUN npm install @material/theme --force
Run npm install jsx-runtime --force
COPY . ./
EXPOSE 3000
CMD [ "npm", "start" ]
在构建docker文件之前,我删除了package.json和node模块,然后在Dockerfile中添加了npm install。它对我有效。