mstruebing mstruebing - 14 days ago 4
Javascript Question

Install yarn in a docker container says missing dependency

I'm using the node:6.7.0 image as my docker container and then follow the installation guide for yarn

sudo apt-key adv --keyserver pgp.mit.edu --recv D101F7899D41F3C3
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list


Then I do

apt-get update && apt-get install yarn


But at this point I get an error message which says

yarn : Depends: nodejs (>= 4.0.0) but it is not going to be installed


I've echoed
node -v
before the install and it also says
6.7.0


Anything that I'm missing?

Answer

robertklep is right - if you check the Dockerfile for Node you'll see they install Node by downloading the TAR, not through APT. You can check this by running an interactive container:

> docker run -it node:6.7.0 bash
root@465fa07437c9:/# dpkg -s nodejs
dpkg-query: package 'nodejs' is not installed and no information is available

You can use NPM in your Dockerfile instead:

FROM node:6.7.0
RUN npm install -g yarn