備忘録

備忘録

LinuxにNode.jsをインストールする方法

Ⅰ. はじめに

タイトルの通り「LinuxにNode.jsをインストールする方法」です。

Ⅱ. やり方(Ubuntu)

1. 以下のコマンドを実行する
// curl -sL https://deb.nodesource.com/setup_21.x | bash -
curl -sL https://deb.nodesource.com/setup_20.x | bash -
// curl -sL https://deb.nodesource.com/setup_19.x | bash -
// curl -sL https://deb.nodesource.com/setup_18.x | bash -
// curl -sL https://deb.nodesource.com/setup_17.x | bash -
// curl -sL https://deb.nodesource.com/setup_16.x | bash -
// curl -sL https://deb.nodesource.com/setup_15.x | bash -
// curl -sL https://deb.nodesource.com/setup_14.x | bash -
// curl -sL https://deb.nodesource.com/setup_13.x | bash -
// curl -sL https://deb.nodesource.com/setup_12.x | bash -
// curl -sL https://deb.nodesource.com/setup_10.x | bash -
// curl -sL https://deb.nodesource.com/setup_8.x | bash -
2. Node.js をインストールする
apt-get install -y nodejs

Ⅲ. やり方(CentOS)

1. 以下のコマンドを実行する
// curl -sL https://rpm.nodesource.com/setup_21.x | sudo bash -
curl -sL https://rpm.nodesource.com/setup_20.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_19.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_18.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_17.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_15.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_13.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_11.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
// curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash -
2. Node.js をインストールする
yum install -y nodejs

実行結果

$ node --version
v18.16.0

$ npm --version
9.5.1