TypeScript で React 開発を行うための環境構築。
Node.js を anyenv で選択可能にする。
環境設定
Homebrew update(2020/09/21 Mon)
$ brew --version
Homebrew 2.4.3
Homebrew/homebrew-core (git revision c0f2a; last commit 2020-07-06)
# To update homebrew itself
$ brew update
$ brew --version
Homebrew 2.5.1
Homebrew/homebrew-core (git revision a0a0f; last commit 2020-09-21)
anyenv install
# install anyenv
$ brew intall anyenv
# すでにインストールされていたため、upgrade
$ brew upgrade anyenv
$ anyenv --version
anyenv 1.1.2
$ anyenv version
nodenv: 12.14.1 (set by /Users/kazuhiro/.anyenv/envs/nodenv/version)
# 環境変数の設定
$ echo 'eval "$(anyenv init -)"' >> ~/.bash_profile
# bash 起動(~/.bash_profile の読み込み)
$ exec $SHELL -l
$ anyenv install nodenv
$ exec $SHELL -l
anyenv plugin install
- anyenv-update
- nodenv-default-packages
# install anyenv-update
$ mkdir -p $(anyenv root)/plugins
$ git clone https://github.com/znz/anyenv-update.git $(anyenv root)/plugins/anyenv-update
# install nodenv-default-pakages
$ mkdir -p "$(nodenv root)"/plugins
$ git clone https://github.com/nodenv/nodenv-default-packages.git "$(nodenv root)/plugins/nodenv-default-packages"
# set default pacakges
$ cat << EOF > $(nodenv root)/default-packages
yarn
typescript
ts-node
typesync
EOF
Node.js intall
$ nodenv install -l
$ nodenv install 14.4.0
$ nodenv global 14.4.0
$ nodenv versions
12.14.1
* 14.4.0 (set by /Users/kazuhiro/.anyenv/envs/nodenv/version)
$ node --version
v14.4.0
package update
# 以下のコマンドですべて更新される
$ anyenv update