I am sorry for my very newbie question, but I am having a terrible day figuring out this error, I have an Express app and I am trying to run it in docker compose. I\'ve used thi
You need to install the dependencies in the container, which is missing from your Dockerfile.
The common way is to create a Dockerfile that is already aware of your application, and make it copy your package.json
file and perform an npm install
.
This allows your container to find all your code dependencies when you later run your application.
See and example here: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/
The sample Dockerfile
:
FROM node:boron
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
You may need to adapt paths for the COPY
command, of course.