skip to Main Content

I used to install nodejs on Debian based container using the following in the Dockerfile:

RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - 
RUN apt-get install nodejs -y 

But I recently started getting the following message:

    => [base 3/7] RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
                               SCRIPT DEPRECATION WARNING
    ================================================================================ 
TO AVOID THIS WAIT MIGRATE THE SCRIPT Continuing in 60 seconds (press Ctrl-C to abort) ...

How do I fix it? How to correctly install nodejs?

2

Answers


  1. According to nodesource/distributions GitHub repository

    Installation Scripts: The installation scripts setup_XX.x are no longer supported and are not needed anymore, as the installation process is straightforward for any RPM and DEB distro.

    So, to install node.js you can use the new way as explainded here

    Installation Instructions Node.js

    If you're root, you could just ommit the sudo

    Download and import the Nodesource GPG key

    sudo apt-get update sudo apt-get install -y ca-certificates curl gnupg
    sudo mkdir -p /etc/apt/keyrings  
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
    

    Create deb repository

    NODE_MAJOR=20  
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
    

    Optional: NODE_MAJOR can be changed depending on the version you need.

    NODE_MAJOR=16  
    NODE_MAJOR=18  
    NODE_MAJOR=20
    

    Run Update and Install

    sudo apt-get update sudo apt-get install nodejs -y
    

    Or you can use the official docker image https://hub.docker.com/_/node/

    Login or Signup to reply.
  2. The notice from the script is

      This script, located at https://deb.nodesource.com/setup_X, used to
      install Node.js is deprecated now and will eventually be made inactive.
    
      Please visit the NodeSource distributions Github and follow the
      instructions to migrate your repo.
      https://github.com/nodesource/distributions 
    
      The NodeSource Node.js Linux distributions GitHub repository contains
      information about which versions of Node.js and which Linux distributions
      are supported and how to install it.
      https://github.com/nodesource/distributions
    

    The instructions on github amount to a Dockerfile RUN

    RUN set -uex; 
        apt-get update; 
        apt-get install -y ca-certificates curl 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=18; 
        echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" > /etc/apt/sources.list.d/nodesource.list; 
        apt-get update; 
        apt-get install nodejs -y;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search