Skip to content

'npm install' in a Dockerfile is not installing all my dependencies. #1005

Description

@AnatoleLucet

So it's pretty strange, i don't have any error, my missing module is listed in my package.json in my container, but the module is not in my node_modules folder.

Here's my Dockerfile :

FROM node:8-alpine
RUN mkdir /app
WORKDIR /app
COPY package.json /app
RUN apk add --no-cache ffmpeg opus pixman cairo pango giflib ca-certificates \
    && apk add --no-cache --virtual .build-deps python g++ make gcc .build-deps curl git pixman-dev cairo-dev pangomm-dev libjpeg-turbo-dev giflib-dev \
    && npm install \
    && apk del .build-deps
COPY . /app
CMD ["npm", "start"]

Here's my docker-compose.yml :

version: '3'
services:
  app:
    build: .
    volumes:
      - ./:/app
      - /app/node_modules
    restart: always
    env_file:
      - .env
    links:
      - mongo
    deploy:
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 3

  mongo:
    image: mongo
    volumes:
      - ~/data:/data/db
    restart: always

  adminmongo:
    image: mrvautin/adminmongo
    ports:
      - 1234:1234
    environment:
      - HOST=0.0.0.0

And my dependencies package.json :

"dependencies": {
    "cleverbot-node": "^0.3.11",
    "discord.js": "github:discordjs/discord.js",
    "enmap": "^4.5.0",
    "googleapis": "^36.0.0",
    "jsonfile": "^5.0.0",
    "mongoose": "^5.3.15",
    "node-gyp": "^3.8.0",
    "node-opus": "^0.3.1",
    "nodemon": "^1.18.9",
    "request": "^2.88.0",
    "xml-js": "^1.6.8",
    "ytdl-core-discord": "^1.0.2"
  },

Just to precise the missing module is "jsonfile" but this is probably because it is the last i've installed.
As i've said when i do a docker-compose build i don't get any error but the 'building' of the container is abnormally long.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions