What is the best practice to install NodeJs and NPM

Hi,

I’m using the image of “FROM arm64v8/debian:12-slim AS runtime”. I need to install node and npm to the container. Currently, I’m installing them using apt install

RUN apt-get update && apt-get install -y --no-install-recommends \
      nodejs=18.20.4+dfsg-1~deb12u1 \
      npm=9.2.0~ds1-1\

I saw there is an article saying it is not good to install nodejs and npm using apt install because the size of the image can grow large (but I can’t find it anymore). So I would like to know what is the best way to install npm and nodejs?

Any help would be appreciated! Thanks

Can you share a link to where you read about that? I would not install some apps from APT repo, if I can install a more specific version from a release page, but I’m not sure about the image size. In some cases libraries can be installed as dependencies that you don’t really need. That would indeed increase the image size, but I don’t know nodejs enough to tell if it oculd happen with its apt package.

I would personally just use an existing base image with the same architecture.

https://hub.docker.com/r/arm64v8/node/

It has debian variants as well. The Dockerfiles are also shared, just click on the variants. So you can get ideas even if you don’t want to use the images.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.