I have the following Dockerfile. It correctly installs /usr/bin/node
but not /usr/bin/npm
. What do I need to add/change to fix this?
FROM php:8.3-apache
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
RUN apt-get update &&
apt-get install -y gnupg &&
mkdir -p /etc/apt/keyrings &&
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg &&
NODE_MAJOR=21 &&
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list &&
apt-get install -y zip mariadb-client libmagickwand-dev chromium nodejs &&
docker-php-ext-install mysqli pdo pdo_mysql exif &&
a2enmod headers rewrite
ENV PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium"
$ which node
/usr/bin/node
$ which npm
$
2
Answers
You did not run
[sudo] apt update
after adding nodesource to the keyring.This should work. Otherwise try inspecting the
$PATH
and check if/usr/local/bin
is there, if not add it. You last option (which was not necessary for a long time) is to dosudo apt-get install npm
.Another way to install both via the Docker image