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] Node.js setup_16.x | bash - on Debian Installation wrong version 18.x #1583

Closed
liang611zh opened this issue Jun 16, 2023 · 9 comments
Labels

Comments

@liang611zh
Copy link

liang611zh commented Jun 16, 2023

Describe your bug
When install node in our pipline, we got a wrong version of node.

Distribution Information:

  • OS: [Debian]
  • script is in the [bitbucket-piplines.yml]
  • Images used:
    docker : php 8.1

Node Version:

  • Node: [Node.js v16.x:]

To Reproduce
Steps to reproduce the behavior:
curl -sL https://deb.nodesource.com/setup_16.x | bash -
apt-get -y install nodejs
node -v

Expected behavior
A clear and concise description of what you expected to happen.
By using the same script.
Before Jun 15 our pipline will install correct version 16.x,
but yesterday this script will install a wrong version 18.x which caused the build process failed.

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2023-06-16 at 13 23 58

@liang611zh liang611zh added the bug label Jun 16, 2023
@antocorso
Copy link

antocorso commented Jun 17, 2023

hello,
I think the problem is that the images php:8.1 (in your case and php:8.2 in my case) have been updated to debian 12 (that isn't in the supported list until now!).
I solved my problem installing nvm choosing the node versione I needed (16)

@WhisperClaims
Copy link

We're having the same issue with our Ruby Node image. Node 18 is installed with breaking changes. Any suggested fix?

@liang611zh
Copy link
Author

hello, I think the problem is that the images php:8.1 (in your case and php:8.2 in my case) have been updated to debian 12 (that isn't in the supported list until now!). I solved my problem installing nvm choosing the node versione I needed (16)

Thank you antocorso, I switched to nvm source for node 16 it works.

But the issue in this case is still there.

@liang611zh
Copy link
Author

We're having the same issue with our Ruby Node image. Node 18 is installed with breaking changes. Any suggested fix?

We have to switch to another source using NVM to install 16.
curl -o- https://github.com/raw/nvm-sh/nvm/v0.39.0/install.sh | bash
source ~/.bashrc
nvm install 16.18.0

ref:
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04

https://deb.nodesource.com/setup_16.x this source with a wrong version, I think they may not support 16 anymore here. Still waiting for response.

@WhisperClaims
Copy link

You're a legend @liang611zh

Splines added a commit to MaMpf-HD/mampf that referenced this issue Jun 20, 2023
also changed shell to bash
We use nvm to install Node.js as nodesource distributions somehow
always install Node.js 18 instead
(see nodesource/distributions#1583)
@o1y
Copy link

o1y commented Jun 23, 2023

This issue seems to be a duplicate of #1579, see #1579 (comment)

tl;dr You have to pin deb.nodesource.com before installing the nodejs package. Otherwise it will use the default debian package sources, which contain node 18.x since Debian Bookworm, which was released on June 10th.

echo "Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 600" > /etc/apt/preferences.d/nodesource

@liang611zh
Copy link
Author

liang611zh commented Jun 23, 2023

This issue seems to be a duplicate of #1579, see #1579 (comment)

tl;dr You have to pin deb.nodesource.com before installing the nodejs package. Otherwise it will use the default debian package sources, which contain node 18.x since Debian Bookworm, which was released on June 10th.

echo "Package: nodejs
Pin: origin deb.nodesource.com
Pin-Priority: 600" > /etc/apt/preferences.d/nodesource

Thank you o1y, I saw your issue before I open this issue. In my case the 'Pin' is not work, but I think your suggestion will help others who have the same problem.

@o1y
Copy link

o1y commented Jun 23, 2023

@liang611zh

After adding the nodesource repository, can you check the output from apt-cache policy nodejs? Maybe you have to adjust the priority.

Splines added a commit to MaMpf-HD/mampf that referenced this issue Jun 26, 2023
* Use npm audit to update npm packages

* Use Node.js version 16 in Docker development

also changed shell to bash
We use nvm to install Node.js as nodesource distributions somehow
always install Node.js 18 instead
(see nodesource/distributions#1583)

* Use node after installation

* Split installation of Node.js to multiple RUN commands

Also alias the default version
If you want to see the full output during Docker build,
you can use the "--progress=plain" option.

* Uniy sass packages and update yarn lock

* Reflect changes in production and test Dockerfiles

* Add comments to Dockerfile and tighten run commands

* Add sass-loader back as dependency

* Switch back to old version of sass-loader

This is because we still use webpacker v4 currently.
We will upgrade this depenedency when we switch from @rails/webpacker
to webpack in the future.

* Use "-no-install-recommends" for yarn install in prod

This is so that Node.js is not installed again, which would result in v18,
which we don't want at the moment.

* Use consistent ${} syntax in Dockerfile & fix Node path

* Copy Node.js over to /usr/local

This ensures that the app user can access node that was previously
installed with nvm in /root/.nvm

* Apply quote arguments suggestion (in code review)

Co-authored-by: Christian Heusel <christian@heusel.eu>

* Quote arguments in other Dockerfiles as well

* Replace deprecated apt-key and improve Dockerfiles

- Replaced Yarn installation with "corepack", a new binary shipped with
Node.js starting with v16. This also means that Yarn is upgraded from v1 to v2
with a different CLI, e.g. we now use "yarn workspaces focus"
instead of "yarn install" to install the dependencies for the workspace
in the current working directory.
- Update GPG key handling during PostgreSQL installation
- Added some more comments to the Dockerfile
- Moved copying of Node.js up in the Dockerfile

More yarn-related changed in subsequent commits.

* Upgrade to Yarn 2 and add packages for non-error webpack build

* Copy Yarn to usr folder alongside other Node.js tooling

* Activate Yarn for app user

* Only copy node over to usr folder

* Go back to Yarn1 and explicitly set Yarn version

- Added a fix so that corepack really installs the version we want
and not some other old version
- with Yarn2+, building curerntly fails, so we switch back to Yarn1 and
deal with an upgrade of Yarn in the future

* Remove ".yarn" from .gitignore

Yarn1 does not generate this folder

* Remove unnecessary dependencies from package.json

"unnecessary" means dependencies that were added when trying out Yarn2+

* Add back missing "--production=false" to "yarn install"

* Use "ruby:3.1.4-bullseye" to have PostgreSQL available

* Add missing `apt update` in dev and test Dockerfiles

Co-authored-by: Christian Heusel <christian@heusel.eu>

* Group `update` and `install` in one RUN statement

(in prod Dockerfile)

* Remove superfluous newline

* Make Node.js version logging one RUN statement

* Explicitly set `--production=true` during `yarn install`

---------

Co-authored-by: Christian Heusel <christian@heusel.eu>
Splines added a commit to MaMpf-HD/mampf that referenced this issue Jun 27, 2023
* Use npm audit to update npm packages

* Use Node.js version 16 in Docker development

also changed shell to bash
We use nvm to install Node.js as nodesource distributions somehow
always install Node.js 18 instead
(see nodesource/distributions#1583)

* Use node after installation

* Split installation of Node.js to multiple RUN commands

Also alias the default version
If you want to see the full output during Docker build,
you can use the "--progress=plain" option.

* Uniy sass packages and update yarn lock

* Reflect changes in production and test Dockerfiles

* Add comments to Dockerfile and tighten run commands

* Add sass-loader back as dependency

* Switch back to old version of sass-loader

This is because we still use webpacker v4 currently.
We will upgrade this depenedency when we switch from @rails/webpacker
to webpack in the future.

* Use "-no-install-recommends" for yarn install in prod

This is so that Node.js is not installed again, which would result in v18,
which we don't want at the moment.

* Use consistent ${} syntax in Dockerfile & fix Node path

* Copy Node.js over to /usr/local

This ensures that the app user can access node that was previously
installed with nvm in /root/.nvm

* Apply quote arguments suggestion (in code review)

Co-authored-by: Christian Heusel <christian@heusel.eu>

* Quote arguments in other Dockerfiles as well

* Replace deprecated apt-key and improve Dockerfiles

- Replaced Yarn installation with "corepack", a new binary shipped with
Node.js starting with v16. This also means that Yarn is upgraded from v1 to v2
with a different CLI, e.g. we now use "yarn workspaces focus"
instead of "yarn install" to install the dependencies for the workspace
in the current working directory.
- Update GPG key handling during PostgreSQL installation
- Added some more comments to the Dockerfile
- Moved copying of Node.js up in the Dockerfile

More yarn-related changed in subsequent commits.

* Upgrade to Yarn 2 and add packages for non-error webpack build

* Copy Yarn to usr folder alongside other Node.js tooling

* Activate Yarn for app user

* Only copy node over to usr folder

* Go back to Yarn1 and explicitly set Yarn version

- Added a fix so that corepack really installs the version we want
and not some other old version
- with Yarn2+, building curerntly fails, so we switch back to Yarn1 and
deal with an upgrade of Yarn in the future

* Remove ".yarn" from .gitignore

Yarn1 does not generate this folder

* Remove unnecessary dependencies from package.json

"unnecessary" means dependencies that were added when trying out Yarn2+

* Add back missing "--production=false" to "yarn install"

* Use "ruby:3.1.4-bullseye" to have PostgreSQL available

* Add missing `apt update` in dev and test Dockerfiles

Co-authored-by: Christian Heusel <christian@heusel.eu>

* Group `update` and `install` in one RUN statement

(in prod Dockerfile)

* Remove superfluous newline

* Make Node.js version logging one RUN statement

* Explicitly set `--production=true` during `yarn install`

---------

Co-authored-by: Christian Heusel <christian@heusel.eu>
@liang611zh
Copy link
Author

liang611zh commented Jun 27, 2023

Looks we found solution to help people who have the same issue.
I think I can closed this issue. Thanks for everyone.

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

4 participants