I'm trying to perform a Docker node/ts project. I don't want dev dependencies, for obvious reasons.
When I run npm --production install
or npm install --omit-dev
or npm --production install --omit-dev
, and/or set NODE_ENV=production
in the Dockerfile, npm is still trying to install prettier which is in my dev deps.
I have tried all options I could think of; docker system prune
, running the docker build with --no-cache
, and even changing the base image in the Dockerfile to "trick" docker into using no cache. Believe me, docker is not caching anything.
What could be happening here? I'm totally at a loss and using --verbose
in the npm install
doesn't add anything useful.
The answers in this question don't work, including the --no-optional
flag.
The Dockerfile (no .dockerignore
used):
FROM node:16
ENV NODE_ENV=production
# -- Setup --
RUN mkdir -p /app/
WORKDIR /app/
# -- Install --
RUN npm update
ADD package.json /app/
RUN npm install --omit-dev --verbose
# -- Copy in source --
COPY .env /app/
COPY src /app/src
## -- Start app --
CMD ["node", "./src/my_app.js"]
p.s. I know I could use something other than npm, but I would prefer to stick with the default option, if I can.
p.p.s Can work around this issue by simply removing the devDependencies
section from my package.json