When I use the following Dockerfile:
`FROM node:22-alpine
ENV NODE_ENV production
WORKDIR /usr/web-server
RUN npm i -g @nestjs/cli typescript
COPY ./package*.json ./
RUN npm install
RUN npm install @types/node
COPY ./ ./
EXPOSE 4000
CMD npm run start:dev`
inside node_modules/@types node folder not installed.
However, if I use the Dockerfile below:
`FROM node:22-alpine
ENV NODE_ENV production
WORKDIR /usr/web-server
RUN npm i -g @nestjs/cli typescript
COPY ./package*.json ./
RUN npm install
COPY ./ ./
EXPOSE 4000
CMD npm uninstall @types/node
&& npm install @types/node
&& npm run start:dev
`
evrething work fine.
Why in first Dockerfile
RUN npm install @types/node
dont install node folder inside @types?
I try to RUN npm install @types/node
after COPY ./ ./
it doesn’t work either