简体   繁体   中英

An unhandled exception occurred: Could not find module “@angular-devkit/build-angular” from "/project into a docker

I am trying to got an image in docker on a way I could write docker-compose up --build and container works.

But I am getting this error when I run docker-compose up after building the image:

An unhandled exception occurred: Could not find module "@angular-devkit/build-angular" from "/project

I solved the problem the problem before by adding RUN npm install --save-dev @angular-devkit/build-angular in the Dockerfile but then other dependencies did not work.

I think is a problem with the folders in docker but I do not know what I am missing.

This is the Dockerfile :

FROM node:12.16.3

# Puerto entorno dev
EXPOSE 4200
# Puerto livereload
EXPOSE 49153
# Puerto Test
EXPOSE 9876
# Puerto e2e
EXPOSE 49152 

RUN apt update

# Instalamos angular cli en nuestra imágen
RUN npm install -g @angular/cli@8

RUN mkdir /project

COPY . /project/

WORKDIR /project

RUN npm install --yes

The docker-compose.yml file:

version: '3.4'

services:
  client-angular:
    image: algoritmofifo
    build: .
    command: ng serve --host 0.0.0.0
    volumes:
      - .:/project  
    ports:
      - 4200:4200
      - 49153:49153
      - 9876:9876
      - 49152:49152
# add `/app/node_modules/.bin` to $PATH
ENV PATH /app/node_modules/.bin:$PATH

# install and cache app dependencies
COPY package.json /app/package.json
RUN npm install
RUN npm install -g @angular/cli@7.3.9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM