プログラミング学習日記

プログラミング学習時のメモ帳。

javascript( ES6 )の環境構築( macOS )

間違っている場所あったら優しく教えてね

javascriptwoローカル環境で実行

まずはじめにHomeBrewのインストールをする

$  brew -v
Homebrew 2.0.5

コマンド入力の結果にバージョンが表示されれば問題はない.インストールされている.

nodebrewをインストールする

https://qiita.com/sinmetal/items/154e81823f386279b33c nodebrewとはnode.jsのバージョンを管理してくれるツールです.

$ brew install nodebrew
updating HomeBrew...

~~長々とupdate~~

Error: The following directories are not writable by your user:
/usr/local/share/info
/usr/local/share/man/man3
/usr/local/share/man/man5

You should change the ownership of these directories to your user.
  sudo chown -R $(whoami) /usr/local/share/info /usr/local/share/man/man3 /usr/local/share/man/man5

And make sure that your user has write permission.
  chmod u+w /usr/local/share/info /usr/local/share/man/man3 /usr/local/share/man/man5

homebrewのupdateができていなかった為そこから実行されました. 待っていたらエラーが返されました.内容は,以下のディレクトリはあなたには書き換えることはできません.という内容.
自分より上の階層に存在しているディレクトリだったので自分では手出しできない模様.エラーメッセージで言われたように管理者権限を与えることにする.

$ sudo chown -R $(whoami) /usr/local/share/info /usr/local/share/man/man3 /usr/local/share/man/man5

$(whoami)は自分の名前が入っている.これ面白いですね.echo $(whoami)と打つと自分の名前が返されました.

もう一度実行する

 ~ $ brew install nodebrew
==> Downloading https://github.com/hokaccha/nodebrew/archive/v1.0.1.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v1.0.1
######################################################################## 100.0%
==> Caveats
You need to manually run setup_dirs to create directories required by nodebrew:
  /usr/local/opt/nodebrew/bin/nodebrew setup_dirs

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 completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/nodebrew/1.0.1: 8 files, 38.6KB, built in 28 seconds

最後にビールマークが表示された.面白い.

$ nodebrew --version
nodebrew 1.0.1

とりあえず入っていることの確認.

 ~ $ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
 ~ $ source ~/.bash_profile
 ~ $ nodebrew setup
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

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

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================
 ~ $ nodebrew install-binary stable
Fetching: https://nodejs.org/dist/v10.15.3/node-v10.15.3-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully
 ~ $ nodebrew use stable
use v10.15.3
 ~ $ node -v
v10.15.3

書かれている通りに実行していく

参考

noderewセットアップ

ブログを見ていただきありがとうございました