marschelpoet
marschelpoet

Reputation: 230

Install Nodejs v18 on Ubuntu 18.04

We are using Azure Pipelines with build agents using Ubuntu 18.04 as OS.

I am currently trying to update the Nodejs version in our pipelines from 16 to 18. Installation of Nodejs is simple enough by using the NodeTool task from Azure Pipelines with versionSpec: "18.x".

However upon using Nodejs afterwards it prompts me for a missing dependency: node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)\

I can even replicate this behavior using docker with the following instructions

docker pull ubuntu:18.04
docker run -it {IMAGE-ID}

# console switches to TTY session for running container…

apt update
apt install curl
curl -fsSL https://deb.nodesource.com/setup_18.x | bash
apt-get install -y nodejs

# checking the node version generates the error above

node -v

The question here might be a little bit overboard, but I am not used to working with linux systems.

Can i easily resolve this dependency for nodejs? Or what would be the general approach here to install the missing dependency?

Upvotes: 10

Views: 22083

Answers (3)

Jürg Lehni
Jürg Lehni

Reputation: 1826

I found a simple solution that doesn't involve recompiling the full Node.js binaries which can take a very long time, especially on embedded systems, by compiling the right version of glibc instead and using patchelf to patch the original binary to work with it.

Detailed instructions can be found here:

https://stackoverflow.com/a/77247394/1163708

Upvotes: 2

Ralle Mc Black
Ralle Mc Black

Reputation: 1203

This message comes during the installation process you mentioned above.

## Run sudo apt-get install -y nodejs` to install Node.js 18.x and npm
## You may also need development tools to build native addons:
sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/enter code hereshare/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-enter code hereby=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.denter code here/yarn.list
sudo apt-get update && sudo apt-get install yarn

I tried that, but still got the same error.

So after a little research it seems that node 18 and ubuntu 18 are not compatible.

https://github.com/nodesource/distributions/issues/1392

If you google the error you will find more about this issue.

Updating to ubuntu 20.04 should fix the problem. If you don't need ubuntu for some other reasons than nodejs, I would suggest you try node:18-alpine. (one of the official nodejs images). Alpine is much more lightweigth than ubuntu.

Upvotes: 5

fkoessler
fkoessler

Reputation: 7257

Until the node team fixes this, you can build NodeJS yourself by following https://github.com/nodejs/node/blob/v18.x/BUILDING.md#unix-and-macos with two exceptions:

sudo apt install gcc-8 g++-8

And then while setting up the build: C=/usr/bin/gcc-8 CXX=/usr/bin/g++-8 ./configure

Credit: https://github.com/nodesource/distributions/issues/1392#issuecomment-1136582618

Upvotes: 1

Related Questions