Categories
Docker

How to fix npm install not installing packages with docker-compose?

Spread the love

Sometimes, we want to fix npm install not installing packages with docker-compose.

In this article, we’ll look at how to fix npm install not installing packages with docker-compose.

How to fix npm install not installing packages with docker-compose?

To fix npm install not installing packages with docker-compose, we should remove the volume setting in our docker-compose.yml file.

For instance, we write

version: "3"
services:
  frontend:
    build: ./frontend
    ports:
      - "8091:8091"
  backend:
    build:
      context: ./backend
      dockerfile: ./Dockerfile.prod
    ports:
      - "8090:8090"

in the docker-compose.yml which has no reference to the volume setting.

This will ensure that the node_modules folder won’t be deleted after npm install is run.

Conclusion

To fix npm install not installing packages with docker-compose, we should remove the volume setting in our docker-compose.yml file.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *