I'm building a Micro-services E-commerce project, I need to create a docker image for each server in my project and run them inside K8s cluster. After successfully creating images for all back-end server I tried creating a docker image for my React front-end app, every time I try creating the image this error happened.
Here is my docker configuration:
FROM node:alpine
WORKDIR /src
COPY package*.json ./
RUN npm install --silent
COPY . .
CMD ["npm ","start"];
Here is the error:
Error: Cannot find module '/src/npm '
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Sometimes it throws an error like this:
webpack output is served from content not from webpack is served from content not from webpack is served from /app/public docker
This is a community wiki answer posted for better visibility. Feel free to expand it.
To resolve described issues, steps below need to be done. 1. Upgrade Dockerfile:
```FROM node:alpine
WORKDIR /src
COPY package*.json ./
RUN npm install --silent
COPY . .
CMD ["npm","start"];
react-scripts
stdin_open: true
to docker-compose file