LoginSignup
1
0

More than 5 years have passed since last update.

MacOSXにReact.js環境を構築する

夜です。眠いです。少し書いたら寝ます。普段はWindows PCのNodistを使ってReact環境を作ってます。
今回はMacで環境を作っていこうと思います。とりあえず、今日はcreate-react-app できるところまで。

brewインストール

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

brewはインストール済みだったぽいので、最新版にアップデート

$ brew update
$ brew -v
> Homebrew 1.7.5

anyenv で開発環境を構築

Nodistと似たような感じで、様々な言語をサポートしてるので anyenv を使います。

$ brew install ndenv
$ ndenv -v
> ndenv 0.4.0

$ echo 'export PATH="$HOME/.ndenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(ndenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l

node自体をインストールするのに、node-build も勧められてるので入れます。

$ git clone https://github.com/riywo/node-build.git $(ndenv root)/plugins/node-build

早速 node をいれます。安定ビルドバージョンの 8.12.0 (2018年9月19日現在)を指定します。

$ ndenv install 8.12.0
/usr/bin/env: bash\r: No such file or directory

!?

bash\r が無いと言っている。どうやらwindowsの改行コードがだめらしい。
dos2unix という改行コード変換を試す。

$ brew install doc2unix

参考にしたコマンドが、ユーザーディレクトリ以下の全てのファイルを変換しようとしたので、あえて掲載しない。正直ミスったと思った。
途中で止めたが、一応動作した。

$ ndenv install v8.12.0
$ ndenv versions
 v8.12.0

$ ndenv global 8.12.0
$ node -v
v8.12.0

yarn インストール

$ brew install yarn --without-node

create-react-app インストール

$ yarn global add create-react-app
$ create-react-app my-app
$ cd my-app
$ yarn start

動いた。寝る。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0