Docker-alpine: npm not found on latest build

Created on 23 Aug 2017  Â·  3Comments  Â·  Source: gliderlabs/docker-alpine

Hi,

I'll try to be as quick as possible. I wanted to migrate one of my projects to docker and I chose Alpine but I was very disappointed to not find npm (it's supposed to be bundled with node).

Here is a c/p of a one line test:

➜  docker run alpine:latest sh -c 'apk update && apk --no-cache add nodejs-current && node -v && npm -v'
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
v3.6.2-94-gd7a2fa1205 [http://dl-cdn.alpinelinux.org/alpine/v3.6/main]
v3.6.2-89-g34a4911e9a [http://dl-cdn.alpinelinux.org/alpine/v3.6/community]
OK: 8440 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.6/community/x86_64/APKINDEX.tar.gz
(1/8) Installing ca-certificates (20161130-r2)
(2/8) Installing libcrypto1.0 (1.0.2k-r0)
(3/8) Installing libgcc (6.3.0-r4)
(4/8) Installing http-parser (2.7.1-r1)
(5/8) Installing libssl1.0 (1.0.2k-r0)
(6/8) Installing libstdc++ (6.3.0-r4)
(7/8) Installing libuv (1.11.0-r1)
(8/8) Installing nodejs-current (7.10.1-r0)
Executing busybox-1.26.2-r5.trigger
Executing ca-certificates-20161130-r2.trigger
OK: 29 MiB in 19 packages
v7.10.1
sh: npm: not found

I found that very strange and decided to try the 3.5 version:

➜ docker run alpine:3.5 sh -c 'apk update && apk --no-cache add nodejs-current && node -v && npm -v'   
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
v3.5.2-165-g9574a8725a [http://dl-cdn.alpinelinux.org/alpine/v3.5/main]
v3.5.2-125-g9cb91a548a [http://dl-cdn.alpinelinux.org/alpine/v3.5/community]
OK: 7962 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/8) Installing ca-certificates (20161130-r1)
(2/8) Installing libcrypto1.0 (1.0.2k-r0)
(3/8) Installing libgcc (6.2.1-r1)
(4/8) Installing http-parser (2.7.1-r0)
(5/8) Installing libssl1.0 (1.0.2k-r0)
(6/8) Installing libstdc++ (6.2.1-r1)
(7/8) Installing libuv (1.9.1-r0)
(8/8) Installing nodejs-current (7.2.1-r1)
Executing busybox-1.25.1-r0.trigger
Executing ca-certificates-20161130-r1.trigger
OK: 46 MiB in 19 packages
v7.2.1
3.10.10

Maybe it is the version 7.10.1 of node?

➜  docker run node:7.10.1 sh -c 'node -v && npm -v'                                                  
v7.10.1
4.2.0

Apparently no so I'm asking you why.
Is it because npm has a broken build (I don't recall which one but I think it's 4.x something)?
Is it for the system to be package manager agnostic (which I find very strange since most of them if not all need npm to be installed)?

Thank you for taking the time and keep up the good work. :)

question

Most helpful comment

Looking at
https://pkgs.alpinelinux.org/contents?file=npm&branch=v3.6&arch=x86_64, it
appears "nodejs-current-npm" is probably the package you're looking for.

All 3 comments

Looking at
https://pkgs.alpinelinux.org/contents?file=npm&branch=v3.6&arch=x86_64, it
appears "nodejs-current-npm" is probably the package you're looking for.

Hmmm. After thinking about it and checking again, it doesn't really seem like such a bad idea, especially since the ambiguous behavior of the company and the questionable work from the team.
Maybe a note somewhere on that particular decision would be worth it.
Thank you for your answer anyway. :)

It is likely separated so that pure node installs or deployments can be smaller. If you don't depend on npm or provide your dependencies another way (such as yarn) then you may never need to install npm. I've seen Node.js packaged like this before on other distributions as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mterzo picture mterzo  Â·  4Comments

konradjurk picture konradjurk  Â·  5Comments

filiptodoric picture filiptodoric  Â·  3Comments

robinmonjo picture robinmonjo  Â·  4Comments

IdanAdar picture IdanAdar  Â·  4Comments