Categories
JavaScript Answers

How to fix Cannot find module for a Node app running in a Docker compose environment?

Spread the love

To fix Cannot find module for a Node app running in a Docker compose environment, we’ve to install the dependencies.

To do this, we write

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" ]

to run npm install with RUN npm install to install the dependencies in our Dockerfile.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *