直接通过sudo apt update nodejs无法升级到v18,应该是apt的版本还没更新
可以通过以下几步完成升级:
1.sudo apt remove nodejs
2.sudo apt autoremove
3.curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
4.sudo apt-get install -y nodejs
安装完成后可以查看版本:
$ node -v
v18.17.1$ npm -v
9.6.7
注:貌似node最近对升级的方式发生了变化,具体请参考
https://github.com/nodesource/distributions
以下为新的方式:
1.Download and import the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo