Getting an error on 'npm run start' line wherein docker cannot find nest (seeing issue in azure pipeline docker build step)
sh: nest: not found
The command '/bin/sh -c npm run build' returned a non-zero code: 127
##[error]The command '/bin/sh -c npm run build' returned a non-zero code: 127
##[error]The process '/usr/bin/docker' failed with exit code 127
Here is my docker file
FROM node:16.13.0-alpine3.14 AS development
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY --chown=node:node package*.json ./
RUN npm install
COPY --chown=node:node . .
FROM node:16.13.0-alpine3.14 AS build
ENV NODE_ENV=production
WORKDIR /usr/src/app
COPY --chown=node:node package*.json ./
COPY --chown=node:node --from=development /usr/src/app/node_modules ./node_modules
COPY --chown=node:node . .
# Run the build command which creates the production bundle
RUN npm run build
ARG BuildId
LABEL test=${BuildId}
RUN npm run test:ci
RUN npm ci --only=production && npm cache clean --force
FROM node:16.13.0-alpine3.14 AS production
ENV NODE_ENV=production
WORKDIR /usr/src/app
USER node
COPY --chown=node:node --from=build /usr/src/app/node_modules ./node_modules
COPY --chown=node:node --from=build /usr/src/app/dist ./dist
CMD [ "node", "dist/main.js" ]
Things I've tried:
- confirming the docker file works fine locally when run with docker build --no-cache
- run docker exec --it on the intermediary stages and confirmed that usr/src/app/node_modules/.bin/nest exists
- Tried running with an adding path ENV PATH="./node_modules/.bin:$PATH"
- Tried adding "RUN npm i -g @nestjs/cli" before the npm run build command
I'm seeing the errors in azure pipeline docker build step.
Please let me know if you see I am doing something wrong or have any suggestions for ways to further debug this issue.