Docker-compose cannt npm install

I starting docker container on google cloud unbutu machine, but when i use

sudo docker-compose up it crushing:

auralab-angular | Node packages may not be installed. Try installing with 'npm install'.
auralab-angular | Error: Could not find the '@angular-devkit/build-angular:dev-server' builder's node package.

this is my dockerfile:

FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
RUN npm install -g @angular/cli
COPY . .

EXPOSE 4200
CMD ["ng", "serve", "--host", "0.0.0.0", "--port", "4200"]

and its working local when i run on my machine with docker-compose file:

sevices:
  angular:
    image: auralab-angular:latest
    container_name: auralab-angular
    build:
      context: ./client
      dockerfile: Dockerfile
    ports:
      - "4200:4200"
    depends_on:
      - django

directory is :

project:
|___client:
|_______Dockerfile
|_______other files;
|___docker-compose.yaml

I am confused, becouse its works on local but not on google machine
I try sudo docker-compose run npm install but still not working.
whyyyy

  • I think you need to make RUN npm install -g @angular/cli before RUN npm install

    – 




  • I have tryed this in previous: ` WORKDIR /app RUN npm install -g @angular/cli COPY package*.json ./ RUN npm install ` but doesnt work this either

    – 




  • I’m not sure why you are trying to start docker compose on the cloud, you should find a way to deploy it without compose, but anyway, did you try to use --build --force-recreate? also, you need to rethink about Dockerfile

    – 




  • Look at this as for example serengetitech.com/tech/…

    – 

Leave a Comment