Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ERROR] Setup_16.x on Debian 12 Bookworm installs v18.13.0 #1579

Closed
o1y opened this issue Jun 15, 2023 · 13 comments
Closed

[ERROR] Setup_16.x on Debian 12 Bookworm installs v18.13.0 #1579

o1y opened this issue Jun 15, 2023 · 13 comments
Labels

Comments

@o1y
Copy link

o1y commented Jun 15, 2023

Describe your bug
When installing node 16.x, the setup script installs node v18.13.0 without any npm package.

Distribution Information:

  • OS: Debian
  • Version 12 Bookworm
  • Docker Base Image: php:8.2-apache

Node Version:

  • Node: v16.x

To Reproduce
Steps to reproduce the behavior:

Use this Dockerfile:

FROM php:8.2-apache

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs

Expected behavior
Installation of node v16.x and npm package.

@o1y o1y added the bug label Jun 15, 2023
@alexk2000
Copy link

alexk2000 commented Jun 15, 2023

The same issue. As workaround decided to use image base on Debian 11 (bullseye): php:8.1-fpm-bullseye

@gaurangblaze
Copy link

Same issue with python docker image. Switched to python:3.11-slim-bullseye to solve this issue (previous image was python:3.11-slim).

@amirredouane
Copy link

You can add 'npm' after nodejs "&& apt-get install -y nodejs npm" in order to solve the problem

@alexk2000
Copy link

No problem to install npm but I expect to install nodejs version 14 but get 18.

@amirredouane
Copy link

I mean the other half of your problem "the setup script installs node v18.13.0 without any npm package"

@riosje
Copy link
Contributor

riosje commented Jun 16, 2023

Hi guys this is an issue with the repositories configuration on your OS, I was not even able to re-produce this behavior.
this resource may help you
https://unix.stackexchange.com/questions/448135/specify-specific-source-apt-repository-for-package

@riosje riosje closed this as completed Jun 16, 2023
@o1y
Copy link
Author

o1y commented Jun 16, 2023

Sorry @riosje, you are right. The script is working correctly.

The challenge is that Debian Bookworm provides a newer Node.js package 18.13.0 from the deb.debian.org repository. On previous Buster, the available version was 10.24.0. The curl script can be a bit misleading, as it suggests that you can install Node.js 16.x and npm by just installing the nodejs package:

## Run `sudo apt-get install -y nodejs` to install Node.js 16.x and npm

But as you already mentioned the solution is to pin the deb.nodesource.com repo first, before installing the nodejs package. Thanks! :)

@gaurangblaze
Copy link

gaurangblaze commented Jun 16, 2023

Thanks for the clarification. How can we pin deb.nodesource.com repo in the Dockerfile? Based on the linked StackExchange answer, does this suffice:

RUN echo "Package: *
Pin: origin deb.nodesource.com
Pin-Priority: 1001" >> /etc/apt/preferences.d/preferences

@o1y
Copy link
Author

o1y commented Jun 16, 2023

@gaurangblaze You could use the following Dockerfile as an example:

FROM php:8.2-apache-bookworm

RUN echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600' > /etc/apt/preferences.d/nodesource \
    && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
    && apt-get install -y nodejs

@liang611zh
Copy link

@gaurangblaze You could use the following Dockerfile as an example:

FROM php:8.2-apache-bookworm

RUN echo 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600' > /etc/apt/preferences.d/nodesource \
    && curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
    && apt-get install -y nodejs

Hi o1y,
When I use this resource, I got a wrong version v18.x, did u figure out how to get the correct version of it?

@BatmanAoD
Copy link

Right now, it appears to me that every script with the following conditions is broken:

  • It uses a Docker image based on Bookworm
  • It uses the nodesource setup-script
  • It uses the command suggested by the setup script for installing Node & npm: apt-get install -y nodejs
  • It requires a version of NodeJS prior to 18, and/or it requires npm

This seems like a fairly common situation, which is why there are already multiple comments in this thread even though Bookworm was released under two weeks ago. Note that prior to this, running the nodesource setup script and then installing nodejs "just worked."

Can the pin command be added to the setup script itself? Alternatively, can the suggested installation command printed by the setup script be updated to explicitly use the newly-added source (i.e. using apt install -t ...)?

@beijaflor
Copy link

@liang611zh

Hi o1y,
When I use this resource, I got a wrong version v18.x, did u figure out how to get the correct version of it?

it works for me

RUN echo "Package: nodejs" >> /etc/apt/preferences.d/preferences && \
    echo "Pin: origin deb.nodesource.com" >> /etc/apt/preferences.d/preferences && \
    echo "Pin-Priority: 1001" >> /etc/apt/preferences.d/preferences

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
    && apt-get install -y nodejs

@BatmanAoD
Copy link

@riosje Can the Pin be added to the nodesource script itself? Without it, the script is effectively broken (as I explained in my comment above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants