Why you should start your Node.JS process without a package manager.


Here is a Grafana graph showing us Prometheus metrics for an Express Node.JS server. On the left is the CPU and memory consumption before switching to using node directly and the right is after.

Each container used around 113MiB before the switch and after around 59MiB of ram.


Run the command your npm or yar start command runs directly without the package manager.


A Dockerfile might look like this.

FROM node:18-alpine

WORKDIR /source
ENV NODE_ENV=production PORT=80
CMD node server.js