How to install Nodejs v13.0.1 in alpine:3.8?

16,125

Solution 1

Alpine nodejs has two repositories for one LTS and one for the current version.

Nodejs LTS:

Package nodejs

Version 12.13.0-r1

Description JavaScript runtime built on V8 engine - LTS version

Project https://nodejs.org/

nodejs-current:

Package nodejs-current

Version 13.0.1-r0

Description JavaScript runtime built on V8 engine - current stable version

Project https://nodejs.org/

If you need current version then you have use nodejs-current

FROM  alpine:3.8
ENV ALPINE_MIRROR "http://dl-cdn.alpinelinux.org/alpine"
RUN echo "${ALPINE_MIRROR}/edge/main" >> /etc/apk/repositories
RUN apk add --no-cache nodejs-current  --repository="http://dl-cdn.alpinelinux.org/alpine/edge/community"
RUN node --version

Solution 2

you can use the follwoing:

FROM alpine:3.8

RUN apk update && apk add --no-cache wget

RUN wget https://nodejs.org/dist/v13.0.1/node-v13.0.1-linux-x64.tar.xz && tar -xf node-v13.0.1-linux-x64.tar.xz

then you will has it in working directory in node-v13.0.1-linux-x64 folder

Share:
16,125
Tien Dung Tran
Author by

Tien Dung Tran

Updated on June 12, 2022

Comments

  • Tien Dung Tran
    Tien Dung Tran almost 2 years

    I am writing a Dockerfile to dockerize a php + nodejs app. so I start from php:7.2.13-fpm-alpine image which is based on alpine:3.8. As study I found that I can add latest alpine repositoriy by command

    apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.10/main/ nodejs
    

    However, with this command, I only got nodejs v10.16.3 while I want a latest one(v13.0.1) Is it possible to achieve it?

  • Cameron Hudson
    Cameron Hudson over 2 years
    For safety, you should also back up the existing file /etc/apk/repositories, and restore it when done.
  • thisismydesign
    thisismydesign over 2 years
    This won't work on other platforms (such as M1 macs) because you're specifying a binary for an explicit platform (x64).