CentOS7にnodebrewを使ってnode.jsをインストールする
CentOS7にnode.jsをインストールしてみたいと思います。
nodebrewを使ってインストール
Node.jsのバージョン管理ツールがあるらしく、nodebrewというみたいです。これを使ってインストールしたいと思います。
nodebrewをインストール
[c] [root@]# curl -L git.io/nodebrew | perl - setup % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0 100 24340 100 24340 0 0 10698 0 0:00:02 0:00:02 --:--:-- 99346 Fetching nodebrew... Installed nodebrew in $HOME/.nodebrew
Export a path to nodebrew: export PATH=$HOME/.nodebrew/current/bin:$PATH
[/c]
環境変数の設定
.bash_profileに以下を追加します。 [c] [root@]# vim ~/.bash_profile
.bash_profile
Get the aliases and functions
if [ -f ~/.bashrc ]; then . ~/.bashrc fi
User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export PATH=$HOME/.nodebrew/current/bin:$PATH #追加
[/c]
追加しました。
.bash_profileを読み込み直します。
[c]
source ~/.bash_profile
nodebrew help
nodebrew 0.9.6
Usage:
nodebrew help Show this message
nodebrew install list
nodebrew ls-remote List remote versions
nodebrew ls-all List remote and installed versions
nodebrew alias
install from binary
nodebrew install-binary v0.10.22
use a specific version number
nodebrew use v0.10.22
io.js
nodebrew install-binary io@v1.0.0 nodebrew use io@v1.0.0 [/c]
バージョン確認します
[c] [root@]# nodebrew ls-remote [/c]
バージョンを指定してインストール
[c]
[root@]# nodebrew install-binary
安定版のインストール
[c] [root@]# nodebrew install-binary stable [/c]
インストールしたNode.jsのバージョン確認
[c] [root@]# nodebrew list v7.0.0 current: none [/c]
Node.jsのバージョンを指定
[c]
[root@]# nodebrew use
Node.jsの安定版を指定
[c] [root@]# nodebrew use stable [/c]
Node.jsとnpmのバージョン確認
[c] [root@]# node -v v7.0.0 [root@]# npm -v 3.10.8 [/c] Nodo.jsのインストールの成功です
