Hi,
instead of running in your host machine npm i ( because by binding your host machine files to container you lose node_modules, to prevent that, beside to bind to /app (with name volume)
you need anonymous volume to keep the the node_module folder ( the problem is similar to lesson 11 of section 5)
so in docker-compose (was update frontend and api services):
version: '3.8'
services:
web:
build: ./frontend
ports:
- 3000:3000
volumes:
# keep node_modules folder with anonymous volume
- /app/node_modules
# bind volume to your host
- ./frontend:/app
api:
build: ./backend
ports:
- 3001:3001
environment:
DB_URL: mongodb://db/vidly
volumes:
# keep node_modules folder with anonymous volume
- /app/node_modules
# bind volume to your host
- ./backend:/app
db:
image: mongo:4.0-xenial
ports:
- 27017:27017
volumes:
- vidly:/data/db
volumes:
vidly: