简体   繁体   中英

From the command line (apk --update add), how to install node.js 'Current latest features' version, instead of 'LTS recommended for most users'?

I have a Docker file with a base image of 'python:alpine'

I need both python and node.js installed in the container, so I start with a python image.

How do I install the latest version of node.js ('Current latest features' of node.js) in the container without specifying a version?

At the time of this post,

RUN apk -v --no-cache --update add nodejs

will install 'LTS Recommended for most users', and not 'current latest features'

Reference: https://nodejs.org/en

At the time of this post:

  • 'LTS recommended for most users': 14.7.6
  • 'Current latest features': 16.9.1

In this example, I want to have 16.9.1 installed instead of 14.7.6 , but not specify a specific version in my Dockerfile


The purpose of this is to lower the maintenance on the Dockerfile, having it pull the latest 'Current - latest features version' always, without having to check the node.js site for a version number, and hard coding that into the Dockerfile.

See this :

"edge" is the name given to the current development tree of Alpine Linux. It consists of a APK repository called "edge" and contains the latest build of all available Alpine Linux packages. Those packages are updated on a regular basis.

And, nodejs-current is the package name for latest feature release, so you could use next:

apk add --no-cache nodejs-current --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community"

Whole run:

/ # apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
v3.14.2-38-g27e4ada230 [https://dl-cdn.alpinelinux.org/alpine/v3.14/main]
v3.14.2-36-g70ff2140e8 [https://dl-cdn.alpinelinux.org/alpine/v3.14/community]
OK: 14938 distinct packages available
/ # apk search --no-cache nodejs-current --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community"
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
nodejs-current-doc-16.9.1-r0
nodejs-current-16.9.1-r0
nodejs-current-dev-16.9.1-r0
/ # apk add --no-cache nodejs-current --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community"
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
(1/8) Installing ca-certificates (20191127-r5)
(2/8) Installing brotli-libs (1.0.9-r5)
(3/8) Installing c-ares (1.17.2-r0)
(4/8) Installing libgcc (10.3.1_git20210424-r2)
(5/8) Installing nghttp2-libs (1.43.0-r0)
(6/8) Installing libstdc++ (10.3.1_git20210424-r2)
(7/8) Installing libuv (1.41.0-r0)
(8/8) Installing nodejs-current (16.9.1-r0)
Executing busybox-1.33.1-r3.trigger
Executing ca-certificates-20191127-r5.trigger
OK: 74 MiB in 22 packages
/ # node -v
v16.9.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM