Ubuntu 安装Node.js

使用Ubuntu的apt安装的nodejs版本为8.x 。不是最新版?

1.下载并执行NodeSource安装脚本(18为所需要下载的版本)

(没有curl 的使用apt安装:sudo apt install curl )

curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -

2.安装Node.js和npm

sudo apt-get install -y nodejs

3.验证Node.js和npm是否已成功安装

node --version  # v18.4.0
npm --version  # v8.12.1

如果出现错误(可以可能是nodejs版本过高)

node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)

卸载装16.x

你可能感兴趣的:(问题系列,ubuntu,node.js,npm)