Comment

David

Very helpful!

I'm encountering an issue with a .cache directory in node_modules. I've got a Dockerfile similar to yours:

FROM node:12.18.2

COPY yarn.lock /yarn.lock
COPY package.json /package.json

ENV NODE_PATH=/node_modules
ENV PATH=$PATH:/node_modules/.bin
RUN yarn

WORKDIR /app
COPY . /app


And in my docker-compose i only have one volume for /app. It looks like when doing docker-compose up (yarn start) a compilation step is creating a local node_modules/.cache directory with subdirectories for babel-loader and eslint-loader. Any idea what is causing that? How can I just have it use the /node_modules location instead?

Replies

Peter Bengtsson

So, within the container you get `/app/node_modules` and you also get a `./node_modules` folder?
It could be that some bad package doesn't respect `$NODE_PATH` which is sad.