How to install Node.js version 16.x.x in a Debian based image (Dockerfile)? (why so hard?)

Date: Tuesday October 5th, 2021

Node 10.x was released on 2018-04-24 (but that’s the default version when using apt-get)

I have needs to have both Python and Node.js installed in running container. I can get the latest version of python in a container using:

FROM python:alpine


FROM python:buster <== Debian based

How do I get the latest version of node.js (16.10.0) installed on Debian (in a Docker container)

Whe I do this:

FROM python:buster

RUN apt-get update && 
  apt-get install -y 
    nodejs npm

I get these versions of node:

node: 10.24.0

npm 5.8.0

and when run in the container give a long statement about no longer being unsupported.

What’s up with the package repo that ‘apt-get’ pulls from, that it will not install later versions of node (14.x or greater)?

If I pull from:

FROM python:alpine

and include these lines
RUN apk -v --no-cache --update add 
    nodejs-current npm

I will get node 16.x version, which makes it easy. I don’t have to do anything else.

Is there something equivalent for python:buster (Debian based)

I would really like a one or two liner in my Dockerfile and not a pages of instructions with a dozen commands to simply get node in the image.

I would appreciate any tested/proven reply. I am sure a number of others have the same question. Other stackoverflow articles on this subject are convoluted and do not provide the simple solution I am hoping to find that is available with pytyon:alpine

There is a reason I need python:debian and cannot use python:alpine in this one use case, otherwise I would chose the latter.

Is there a way some how to get a package repo maintainers attention to show me how to get a recent version (14..16), into the apt-get repository?

It appears many people are having issues with this.

Read more here: Source link