Missing `node_modules` in Docker Container Missing `node_modules` in Docker Container docker docker

Missing `node_modules` in Docker Container


Then why don't you create this directory at build (ie adding the following line in your Dockerfile before RUN npm install) ?

RUN mkdir <workdir>/node_modules

(Replace <workdir> with the actual default working dir of the keymetrics/pm2 image)


I would say it is a directory issue.You will want to set

ENV ROOT /usr/src/appWORKDIR ${ROOT}

before

# Bundle APP filesCOPY package.json .

example:

FROM node:8ENV ROOT /usr/src/appWORKDIR ${ROOT}COPY package*.json ./RUN yarn -i --quiet# Bundle app sourceCOPY . .ENV NODE_ENV developmentCMD yarn run start:devEXPOSE 3000


I had same issue, related to invalid package.json file, especially name field. After removing white spaces in name field, it created node_modules properly. So maybe pay attention if you have such errors.enter image description here