Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 916
Tien Dung Tran Avatar asked Nov 06 '19 07:11

Tien Dung Tran


People also ask

Does alpine have nodejs?

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

Does node alpine include NPM?

No, it doesn't come with npm.

What version is node alpine?

(Background: At the time of writing, node:14-alpine is 14.17. 1 , whereas the latest minor Node. js version of 14 is 14.17.


2 Answers

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
like image 137
Adiii Avatar answered Oct 12 '22 18:10

Adiii


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

like image 5
LinPy Avatar answered Oct 12 '22 17:10

LinPy