Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular does not work in docker because it can not find module @angular-devkit/build-angular

I tried ignoring the node_modules but still is not working for me ,even after ignoring the node_modules im still facing the same error

yaml file:

version: '3.5'

services:
    angular-docker:
        hostname: localhost
        container_name: angular-docker
        build: ./angular-doc
        volumes:
          - './angular-doc:/usr/src/app/'
        ports:
          - '4200:4200'

docker file:

FROM node:10.12.0

RUN mkdir usr/src/app

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install -g @angular/cli@latest

COPY . .

EXPOSE 4200

CMD ng serve --host 0.0.0.0
like image 439
Venkat Avatar asked Nov 07 '22 19:11

Venkat


1 Answers

You need to install @angular-devkit/build-angular package as dev dependency in your angular project

npm install --save-dev @angular-devkit/build-angular

Updated!

you have forget to add RUN npm install in the docker file

FROM node:10.12.0
RUN mkdir usr/src/app
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
RUN npm install -g @angular/cli@latest
COPY . .
EXPOSE 4200
CMD ng serve --host 0.0.0.0
like image 162
Muhammed Albarmavi Avatar answered Nov 11 '22 12:11

Muhammed Albarmavi