流れ
- Node.jsとnpmのインストール
- AppCenter CLIのインストール
1. Node.jsとnpmのインストール
1.1 nodeバージョン管理ツールをインストール
ターミナルで以下コマンドを実行
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1.2 nodebrewのインストール
ターミナルで以下コマンドを実行
$ brew install nodebrew
正常にインストールされているかバージョン確認コマンドを実行して確認
$ nodebrew -v
こんな感じに表示されたらOK
nodebrew 1.0.0
Usage:
nodebrew help Show this message
nodebrew install <version> Download and install <version> (from binary)
nodebrew compile <version> Download and install <version> (from source)
nodebrew install-binary <version> Alias of `install` (For backword compatibility)
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
nodebrew install v8.9.4
# use a specific version number
nodebrew use v8.9.4
1.3 Node.jsとnpmのインストール
最新のNode.jsをインストール
バージョンを指定したい場合はlatest
の部分をv1.1.1
のように変更すればOK
※install-binary
でやってるのはinstall
だと同時にコンパイルされちゃって時間がかかるから
$ nodebrew install-binary latest
こんなエラーが出たら
Fetching: https://nodejs.org/dist/v8.1.2/node-v8.1.2-darwin-x64.tar.gz
Warning: Failed to create the file
Warning: /Users/take/.nodebrew/src/v8.1.2/node-v8.1.2-darwin-x64.tar.gz: No
Warning: such file or directory
0.0%
curl: (23) Failed writing body (0 != 941)
download failed: https://nodejs.org/dist/v8.1.2/node-v8.1.2-darwin-x64.tar.gz
ディレクトリを作ってあげると解決する
$ mkdir -p ~/.nodebrew/src
インストールされているかNode.jsのバージョンを確認する
$ nodebrew list
こんな感じで出力されたらOK
v10.9.0
current: none
current
がnone
になっているから、使用するバージョンを有効化してあげる
$ nodebrew use v10.9.0
こんな感じに出力されたらOK
use v10.9.0
パスを通す
xxxxx
にはpwdで確認できる
$ echo 'export PATH=$PATH:/Users/xxxxx/.nodebrew/current/bin' >> ~/.bashrc
更に.bashrcを.bash_profileで読み込むようにする
viか何かで~/.bash_profile
を開いて
vi ~/.bash_profile
以下を追記
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Node.jsのバージョンを確認する
$ node -v
こんな感じに出力されたらOK
v10.9.0
npmのバージョンを確認する
$ npm -v
こんな感じに出力されたらOK
v6.2.0
これでNode.jsとnpmのインストールは終了
2. AppCenter CLIのインストール
以下コマンドを使用してインストールします
npm install -g appcenter-cli
バージョン確認コマンドを使用してインストールされているか確認します
appcenter --version
こんな感じに出力されたらOK
appcenter version 1.1.1
これでAppCenter CLIを使うための準備は終了