I have a docker which install nodejs and npm. It used to work fine previously but since today it has stared to crash with following error.
------
> [assets 4/9] RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs && npm i npm@latest -g:
#8 67.38 Setting up nodejs (16.20.2-deb-1nodesource1) ...
#8 67.82 npm ERR! code EBADENGINE
#8 67.82 npm ERR! engine Unsupported engine
#8 67.82 npm ERR! engine Not compatible with your version of node/npm: [email protected]
#8 67.82 npm ERR! notsup Not compatible with your version of node/npm: [email protected]
#8 67.82 npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"}
#8 67.82 npm ERR! notsup Actual: {"npm":"8.19.4","node":"v16.20.2"}
#8 67.82 npm ERR! A complete log of this run can be found in:
#8 67.82 npm ERR! /root/.npm/_logs/2023-09-01T07_07_39_330Z-debug-0.log
------
Docker file.
FROM ubuntu:18.04
ENV TMPDIR=/tmp
RUN apt-get update -y \
&& apt-get upgrade -y \
&& DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \
curl \
software-properties-common \
bzip2 \
git
RUN DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y \
firefox \
chromium-browser
# Install Node
RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y \
nodejs \
&& npm i npm@latest -g
ENV CHROMIUM_BIN=/usr/bin/chromium-browser
RUN rm -rf /app/*
COPY ./code/ /app/
WORKDIR /app
RUN rm -rf node_modules \
&& rm -rf ./static/vendor
RUN npm ci --legacy-peer-deps
I also see some warning related to installation of nodejs command.
#0 0.297 ================================================================================
#0 0.297 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
#0 0.297 ================================================================================
#0 0.297
#0 0.297 SCRIPT DEPRECATION WARNING
#0 0.297
#0 0.297
#0 0.297 This script, located at https://deb.nodesource.com/setup_X, used to
#0 0.297 install Node.js is deprecated now and will eventually be made inactive.
#0 0.297
#0 0.297 Please visit the NodeSource distributions Github and follow the
#0 0.297 instructions to migrate your repo.
#0 0.297 https://github.com/nodesource/distributions
#0 0.297
#0 0.297 The NodeSource Node.js Linux distributions GitHub repository contains
#0 0.297 information about which versions of Node.js and which Linux distributions
#0 0.297 are supported and how to install it.
#0 0.297 https://github.com/nodesource/distributions
#0 0.297
#0 0.297
#0 0.297 SCRIPT DEPRECATION WARNING
#0 0.297
#0 0.297 ================================================================================
#0 0.297 ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
#0 0.297 ================================================================================
So what is the other best way to insatll Nodejs with docker.
This seems to be caused by an npm 10 release
https://github.com/npm/cli/releases/tag/v10.0.0
support for node 14 and 16 has been dropped. npm now supports node ^18.17.0 || >=20.5.0
Try installing npm 9 in your Dockerfile instead:
npm i npm@9 -g
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