10000hの技術メモ

この先生きのこるための勉強内容&時間記録

Electronではじめるアプリ開発 2-1 Node.jsをインストールする

Electronを本で勉強。

Electronではじめるアプリ開発 ~JavaScript/HTML/CSSでデスクトップアプリを作ろう

Electronではじめるアプリ開発 ~JavaScript/HTML/CSSでデスクトップアプリを作ろう

nodebrewのインストール

brew install nodebrew

出力結果

rrcs-172-254-99-29:~ yoshikiito$ brew install nodebrew
Error: /usr/local is not writable. You should change the ownership
and permissions of /usr/local back to your user account:
  sudo chown -R $(whoami) /usr/local
Warning: You are using OS X 10.12.
We do not provide support for this pre-release version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
==> Using the sandbox
==> Downloading https://github.com/hokaccha/nodebrew/archive/v0.9.6.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v0.9.6
######################################################################## 100.0%
==> /usr/local/Cellar/nodebrew/0.9.6/bin/nodebrew setup_dirs
==> Caveats
Add path:
  export PATH=$HOME/.nodebrew/current/bin:$PATH

To use Homebrew's directories rather than ~/.nodebrew add to your profile:
  export NODEBREW_ROOT=/usr/local/var/nodebrew

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/nodebrew/0.9.6: 7 files, 36.8K, built in 3 seconds

Warningが出てる。若干不安だけども、続けて。セットアップ。

yoshikiito$ nodebrew setup
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================

.bash_profileの設定

yoshikiito$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
yoshikiito$ source ~/.bash_profile

nodebrew -versionで表示されることを確認。

yoshikiito$ nodebrew -version
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

できたっぽい。

Node.jsのインストール

最新が出ているものの、本のバージョンにあわせてv6.10.0を選択してインストール。

yoshikiito$ nodebrew install-binary v6.10.0
Fetching: https://nodejs.org/dist/v6.10.0/node-v6.10.0-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully

インストールしただけだと使えないので、nodebrew use バージョンするか、一つしか入れていないのでnodebrew use stableでも、nodebrew use latestでも結果は一緒っぽい。(ぽいばっかりだな・・・)

yoshikiito$ nodebrew use stable
use v6.10.0

ここまでやったら、node -vで確認。

yoshikiito$ node -v
v6.10.0

OK。

参考

Node.jsをMacにインストール!(Homebrew→Nodebrew→Node.js順にインストール) - モーリーのメモ

今回の勉強時間:22分 累計勉強時間:14時間33分