How To Install Node.js on Ubuntu 20.04 | DigitalOcean
ubuntu20上默认用apt install 安装的nodejs版本是 v10.几
官方提供了对应的脚本, 下面的setup_19.x 如果你需要v18,就把19改成18.
# node 安装较新的版本
curl -sL https://deb.nodesource.com/setup_19.x -o /tmp/nodesource_setup.sh
sudo bash /tmp/nodesource_setup.sh
# The PPA will be added to your configuration and your local package cache will be updated automatically.
# You can now install the Node.js package in the same way you did in the previous section:
sudo apt install nodejs
node -v
还有一种方法是使用node version manger, nvm文章来源:https://www.toymoban.com/news/detail-584364.html
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
source ~/.bashrc
nvm list-remote
Output
. . .
v18.0.0
v18.1.0
v18.2.0
v18.3.0
v18.4.0
v18.5.0
v18.6.0
v18.7.0
v18.8.0
v18.9.0
v18.9.1
v18.10.0
v18.11.0
v18.12.0 (LTS: Hydrogen)
v18.12.1 (LTS: Hydrogen)
v18.13.0 (Latest LTS: Hydrogen)
v19.0.0
v19.0.1
v19.1.0
v19.2.0
v19.3.0
v19.4.0
nvm install v14.10.0
卸载nodejs文章来源地址https://www.toymoban.com/news/detail-584364.html
sudo apt remove nodejs
nvm uninstall node_version
到了这里,关于ubuntu 20.04上安装更新的nodejs的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!