CentOS7にnodebrewを使ってnode.jsをインストールする

CentOS7にnode.jsをインストールしてみたいと思います。

nodebrewを使ってインストール

Node.jsのバージョン管理ツールがあるらしく、nodebrewというみたいです。これを使ってインストールしたいと思います。

nodebrewをインストール

01[root@]# curl -L git.io/nodebrew | perl - setup
02 
03  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
04                                 Dload  Upload   Total   Spent    Left  Speed
05  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
06  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
07  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
08100 24340  100 24340    0     0  10698      0  0:00:02  0:00:02 --:--:-- 99346
09Fetching nodebrew...
10Installed nodebrew in $HOME/.nodebrew
11 
12========================================
13Export a path to nodebrew:
14 
15export PATH=$HOME/.nodebrew/current/bin:$PATH
16========================================

環境変数の設定

.bash_profileに以下を追加します。

01[root@]# vim ~/.bash_profile
02# .bash_profile
03 
04# Get the aliases and functions
05if [ -f ~/.bashrc ]; then
06        . ~/.bashrc
07fi
08 
09# User specific environment and startup programs
10 
11PATH=$PATH:$HOME/bin
12 
13export PATH
14export PATH=$HOME/.nodebrew/current/bin:$PATH #追加

追加しました。

.bash_profileを読み込み直します。

01source ~/.bash_profile
02nodebrew help
03 
04nodebrew 0.9.6
05 
06Usage:
07    nodebrew help                         Show this message
08    nodebrew install <version>            Download and install <version> (compile from source)
09    nodebrew install-binary <version>     Download and install <version> (binary file)
10    nodebrew uninstall <version>          Uninstall <version>
11    nodebrew use <version>                Use <version>
12    nodebrew list                         List installed versions
13    nodebrew ls                           Alias for `list`
14    nodebrew ls-remote                    List remote versions
15    nodebrew ls-all                       List remote and installed versions
16    nodebrew alias <key> <value>          Set alias
17    nodebrew unalias <key>                Remove alias
18    nodebrew clean <version> | all        Remove source file
19    nodebrew selfupdate                   Update nodebrew
20    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
21    nodebrew exec <version> -- <command>  Execute <command> using specified <version>
22 
23Example:
24    # install from binary
25    nodebrew install-binary v0.10.22
26 
27    # use a specific version number
28    nodebrew use v0.10.22
29 
30    # io.js
31    nodebrew install-binary io@v1.0.0
32    nodebrew use io@v1.0.0

バージョン確認します

バージョンを指定してインストール

1[root@]# nodebrew install-binary <version>

安定版のインストール

1[root@]# nodebrew install-binary stable

インストールしたNode.jsのバージョン確認

1[root@]# nodebrew list
2v7.0.0
3 
4current: none

Node.jsのバージョンを指定

Node.jsの安定版を指定

Node.jsとnpmのバージョン確認

1[root@]# node -v
2v7.0.0
3 
4[root@]# npm -v
53.10.8

Nodo.jsのインストールの成功です

個人支援・寄付について

サイトラボでは個人支援・寄付を受けております。ご協力いただける方はお願いいたします。当サイトではビットコインで受け付けております。

  • ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS