LoginSignup
47
31

Ubuntu で Node の最新版/推奨版を使う (n コマンド編)

Last updated at Posted at 2021-11-03

Ubuntu 20.04 に Node の最新版、安定版を切り替えて使うために n コマンドを導入します。
nコマンドは npm から導入できます。

nコマンド導入

sudo apt install nodejs npm
sudo npm install n -g

推奨版(lts) のインストール

sudo n lts
#   installed : v16.13.0 (with npm 8.1.0)

最新版(latest)のインストール

sudo n latest
#   installed : v17.0.1 (with npm 8.1.0)

古い nodejs npm の削除

sudo apt purge nodejs npm

各バージョン

無事にインストールされましたか、バージョンを確認します。

npm -v
# 8.1.0

node -v
# v17.0.1

n --version
# v8.0.0

インストール済みのバージョンを切り替える (推奨版/最新版を切り替える) (sudo n)

sudo n で切り替えることができます。
カーソルキーで選択しリターンキーでインストールできます。
image.png

47
31
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
47
31