ENOENT: PS, Spawn PS - Common Issues when Working with Nestjs, Nodejs and Docker
Working Environment:
- VsCode
- Debug Mode
- Nestjs
- Dockerfile
What did that happened?
After i ran docker compose up and then i change some file content in my local machine , it will trigger changed in the file system between local and remote host.
Error message:
auth-1 | Info Webpack is building your sources...
auth-1 |
auth-1 | webpack 5.97.1 compiled successfully in 30 ms
auth-1 | /bin/sh: 1: ps: not found
auth-1 | node:events:497
auth-1 | throw er; // Unhandled 'error' event
auth-1 | ^
auth-1 |
auth-1 | Error: spawn ps ENOENT
auth-1 | at ChildProcess._handle.onexit (node:internal/child_process:286:19)
auth-1 | at onErrorNT (node:internal/child_process:484:16)
auth-1 | at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
auth-1 | Emitted 'error' event on ChildProcess instance at:
auth-1 | at ChildProcess._handle.onexit (node:internal/child_process:292:12)
auth-1 | at onErrorNT (node:internal/child_process:484:16)
auth-1 | at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
auth-1 | errno: -2,
auth-1 | code: 'ENOENT',
auth-1 | syscall: 'spawn ps',
auth-1 | path: 'ps',
auth-1 | spawnargs: [ '-o', 'pid', '--no-headers', '--ppid', 44 ]
auth-1 | }
auth-1 |
auth-1 | Node.js v21.7.3
Problem: The problem is the docker container image you're using is missing procps
Solution:
Insert this line into your dockerfile:
RUN apt-get update && apt-get install -y procps
Example:
FROM node:21-bullseye-slim as development
RUN apt-get update && apt-get install -y procps
WORKDIR /usr/src/app
COPY package.json ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json
COPY apps/auth/prisma ./prisma
No Comments