CentOS7にyumでnode.jsをインストールする

追記

環境構築スクリプトを使えばnginx.node.jsの環境がすぐ手に入ります。 CentOS7にnode.jsをインストールしてみます

リポジトリの追加

[c] [root@localhost ~]# curl -sL https://rpm.nodesource.com/setup\_8.x | bash -

Installing the NodeSource Node.js 8.x LTS Carbon repo...

Inspecting system...

  • rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
  • uname -m

Confirming "el7-x86_64" is supported...

Downloading release setup RPM...

Installing release setup RPM...

  • rpm -i --nosignature --force '/tmp/tmp.88OiDHZxLP'

Cleaning up...

  • rm -f '/tmp/tmp.88OiDHZxLP'

Checking for existing installations...

  • rpm -qa 'node|npm' | grep -v nodesource

Run sudo yum install -y nodejs to install Node.js 8.x LTS Carbon and npm.

You may also need development tools to build native addons:

sudo yum install gcc-c++ make

To install the Yarn package manager, run:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo sudo yum install yarn [/c]

インストール

[c] [root@localhost ~]# yum install nodejs gcc-c++ make 読み込んだプラグイン:fastestmirror Loading mirror speeds from cached hostfile epel/x86_64/metalink | 8.5 kB 00:00:00 * elrepo: ftp.ne.jp * epel: ftp.iij.ad.jp * ius: mirrors.tuna.tsinghua.edu.cn base | 3.6 kB 00:00:00 elrepo | 2.9 kB 00:00:00 extras | 3.4 kB 00:00:00 ius | 2.3 kB 00:00:00 nginx | 2.9 kB 00:00:00 nodesource | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/4): extras/7/x86_64/primary_db | 205 kB 00:00:00 (2/4): nodesource/x86_64/primary_db | 39 kB 00:00:00 (3/4): ius/x86_64/primary_db | 406 kB 00:00:02 (4/4): elrepo/primary_db | 531 kB 00:00:03 パッケージ gcc-c++-4.8.5-28.el7_5.1.x86_64 はインストール済みか最新バージョンです パッケージ 1:make-3.82-23.el7.x86_64 はインストール済みか最新バージョンです 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ nodejs.x86_64 2:8.12.0-1nodesource を インストール --> 依存性解決を終了しました。 依存性を解決しました

Package アーキテクチャー バージョン リポジトリー 容量

インストール中: nodejs x86_64 2:8.12.0-1nodesource nodesource 16 M トランザクションの要約

インストール 1 パッケージ 総ダウンロード容量: 16 M インストール容量: 49 M Is this ok [y/d/N]: y Downloading packages: 警告: /var/cache/yum/x86_64/7/nodesource/packages/nodejs-8.12.0-1nodesource.x86_64.rpm: ヘッダー V4 RSA/SHA256 Signature、鍵 ID 34fa74dd: NOKEY 61% [=================================================================================- ] 5.5 MB/s | 9.9 MB 00:00:01 ETA nodejs-8.12.0-1nodesource.x86_64.rpm の公開鍵がインストールされていません nodejs-8.12.0-1nodesource.x86_64.rpm | 16 MB 00:00:01 file:///etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL から鍵を取得中です。 Importing GPG key 0x34FA74DD: Userid : "NodeSource gpg-rpm@nodesource.com" Fingerprint: 2e55 207a 95d9 944b 0cc9 3261 5ddb e8d4 34fa 74dd Package : nodesource-release-el7-1.noarch (installed) From : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL 上記の処理を行います。よろしいでしょうか? [y/N]y Running transaction check Running transaction test Transaction test succeeded Running transaction 警告: RPMDB は yum 以外で変更されました。 インストール中 : 2:nodejs-8.12.0-1nodesource.x86_64 1/1 検証中 : 2:nodejs-8.12.0-1nodesource.x86_64 1/1 インストール: nodejs.x86_64 2:8.12.0-1nodesource 完了しました! [/c] 無事インストールできました