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 <version> Download and install <version> (compile from source)
nodebrew install-binary <version> Download and install <version> (binary file)
nodebrew uninstall <version> Uninstall <version>
nodebrew use <version> Use <version>
nodebrew list List installed versions
nodebrew ls Alias for `list`
nodebrew ls-remote List remote versions
nodebrew ls-all List remote and installed versions
nodebrew alias <key> <value> Set alias
nodebrew unalias <key> Remove alias
nodebrew clean <version> | all Remove source file
nodebrew selfupdate Update nodebrew
nodebrew migrate-package <version> Install global NPM packages contained in <version> to current version
nodebrew exec <version> -- <command> Execute <command> using specified <version>

Example:
# 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 <version>
[/c]

安定版のインストール

[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 <version>
[/c]

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のインストールの成功です

個人支援・寄付について

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

  • ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS