#Module not found after angular installation via docker

7 messages · Page 1 of 1 (latest)

gaunt turtle
#

Hi every one,

i make a sap application with a angular(front) and the module can't be found

  1. node and all the dependencis are work with a docker file and docker compose

# Aller dans le dossier Angular
WORKDIR /app/angular

# Copier uniquement les fichiers nécessaires pour les dépendances
COPY angular/package*.json ./

# Installer dépendances
RUN npm install -g @angular/cli \
    && npm install 

# Copier le reste du projet
COPY angular/ ./

EXPOSE 4200

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

# docker build -f angular/Dockerfile.angular -t logisticants-angular .

# docker run -it --rm logisticants-angular sh  ```

docker compose

```   angular:
    build:
      context: .
      dockerfile: angular/Dockerfile.angular
    container_name: logisticants-angular
    ports:
      - "4200:4200"
    volumes:
      - ./angular:/app/angular
      - /app/angular/node_modules
    networks:
      - mynetwork  ```

the container work and i can execute npm to installe packages (like vitest and angular) 

so, when i work and created front content (model, service, component and test) the modules are not found on my project

``` Cannot find module '@angular/core' or its corresponding type declarations. ``` 

also, the dependance are on my package.json

help me pls
near tendon
#

This is a classic Docker + Angular + bind volume issue.

The main clue I think, is this part:

#

volumes:

  • ./angular:/app/angular
  • /app/angular/node_modules
#

The image installs node_modules during build, but then Docker Compose mounts your local ./angular folder over /app/angular.

That can hide or confuse the installed dependencies, especially if the local project does not have node_modules, or the IDE is checking the local files instead of the container files.

Most likely cause:

Inside the container, Angular probably has node_modules.

But on the host machine, your editor/VS Code may not see them.

#

Try this:

  1. On your host machine:

cd angular

npm install

Then restart VS Code / TypeScript server.

  1. Rebuild Docker cleanly:

docker compose down -v

docker compose up --build

  1. Check inside the container:

docker exec -it logisticants-angular sh

npm list @angular/core

ls node_modules/@angular/core

If @angular/core is missing there, dependencies are not installed in the running container.

I would also change your compose volume to a named node_modules volume:

volumes:

./angular:/app/angular

angular_node_modules:/app/angular/node_modules

And add at the bottom:

volumes:

angular_node_modules:

Then run docker compose down -v and docker compose up --build again.

#

This may not be a 100% fix, but it is my best guess given the context, hopefully this helps 🙂

cursive geyser