V
V
veryoriginalnickname2021-06-01 02:36:01
Docker
veryoriginalnickname, 2021-06-01 02:36:01

How to make friends between Docker and node_modules?

Here is such a Dockerfile:

FROM node:16.2-alpine3.12
ENV CONTAINER_PATH /usr/src/front
WORKDIR $CONTAINER_PATH
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "run", "serve"]

The problem is that npm run serve stupidly doesn't work, it complains about "sh: vue-cli-service: not found". For now, the solution for this is to keep node_modules in the project folder. Is it possible to somehow do without this (so that node_modules is only in Docker)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
veryoriginalnickname, 2021-06-01
@veryoriginalnickname

Seems to have fixed (docker compose file example):

front:
    container_name: front
    image: front
    restart: unless-stopped
    build:
      context: ./front
      dockerfile: Dockerfile
    volumes:
      - "./front:/usr/src/front"
      - /usr/src/front/node_modules <----- надо было добавить это
    ports:
      - 4444:8080

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question