node:internal/modules/cjs/loader:1148 throw err; ^ Error: Cannot find module '/app/index.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15) at Module._load (node:internal/modules/cjs/loader:986:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12) at node:internal/main/run_main_module:28:49 { code: 'MODULE_NOT_FOUND', requireStack: [] }
getting above error while running docker image of express server
tried with npm install express in docker file below is my docker file
# Use an official Node.js runtime as a parent image
FROM node:20
# Set the working directory in the container
WORKDIR /app
# Copy the package.json and package-lock.json files
COPY package*.json ./
# Install dependencies
RUN npm install express
# Copy the rest of the application code
COPY . .
# Expose the port the app runs on
EXPOSE 5000
# Command to run the application
CMD ["node", "index.js"]
i have checked my directory index.js file is properly placed
docker run -vor Composevolumes:block if you have one.RUN npm ibefore the second copy command