When I run below commands in a Dockerfile:
FROM ruby:2.3
RUN apt-get update
RUN apt-get install nodejs npm -y
RUN apt-get install vim -y
RUN apt-get install memcached -y
I get below error:
Sending build context to Docker daemon 29.74MB
Step 1/12 : FROM ruby:2.3
---> 09c6ceeef3bc
Step 2/12 : RUN apt-get update
---> Using cache
---> c41c3235c3ba
Step 3/12 : RUN apt-get install nodejs npm -y
---> Running in b0d407900cbd
Reading package lists...
Building dependency tree...
Reading state information...
**E: Unable to locate package npm
The command '/bin/sh -c apt-get install nodejs npm -y' returned a non-zero code: 100**
Please suggest a solution, thank you in advance.
Docker image ruby:2.3 is based on Debian 9 Stretch where is older nodejs package and no npm package.
You can do it like this:
RUN apt-get update; \
apt-get install -y curl gnupg; \
curl -sL https://deb.nodesource.com/setup_8.x | bash -; \
apt-get install -y nodejs; \
rm -rf /var/lib/apt/lists/*
At first it installs curl to be able to download setup script and gnupg is needed by that setup script.
You can read more on nodejs official web: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With