简体   繁体   English

在 Ubuntu 18.04 上安装 Nodejs v18

[英]Install Nodejs v18 on Ubuntu 18.04

We are using Azure Pipelines with build agents using Ubuntu 18.04 as OS.我们将 Azure Pipelines 与使用 Ubuntu 18.04 作为操作系统的构建代理一起使用。

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" .我目前正在尝试将我们管道中的 Nodejs 版本从 16 更新到 18。Nodejs 的安装非常简单,只需使用Azure Pipelines 中的 NodeTool 任务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)\然而,在之后使用 Nodejs 时,它提示我缺少依赖项: 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 复制此行为

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.这里的问题可能有点过分,但我不习惯使用 linux 系统。

Can i easily resolve this dependency for nodejs?我可以轻松解决 nodejs 的这种依赖关系吗? Or what would be the general approach here to install the missing dependency?或者这里安装缺少的依赖项的一般方法是什么?

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 same error.我试过了,但仍然是同样的错误。

So after a little research it seams that node 18 and ubuntu 18 are not combatible.因此,经过一些研究后发现 node 18 和 ubuntu 18 是不兼容的。

https://github.com/nodesource/distributions/issues/1392 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.更新到 ubuntu 20.04 应该可以解决这个问题。 If you dont need ubuntu for some other reasons than nodejs, i would suggest you to try node:18-alpine.如果你因为 nodejs 以外的其他原因不需要 ubuntu,我建议你尝试 node:18-alpine。 (one of the ufficial nodejs images). (官方 nodejs 图像之一)。 Alpine is much more lightweigth than ubuntu. Alpine 比 ubuntu 轻量级得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM