LoginSignup
0
0

More than 3 years have passed since last update.

macでruby on railsの環境構築

Posted at

新しいMacが届いたので、rubyで開発環境を作ることにした

ruby ruby 2.6.3p62
rails 6

rails new xxxx

でまずはプロジェクトを作った

rails s

でロカールにアクセスしたら表示ができなかった。。。

ログを見たら

Please run rails webpacker:install Error:

が出てた

webpackが無いのね

rails webpacker:install

を実行したら

sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js  

が出た。。。

なかなか進まない

nodeのインストールの準備
brew install nodebrew
をやって
nodebrew -v
で確認

nodeのインストール

nodebrew ls-remote でインストールできるバージョンの確認
nodebrew install-binary latest で最新をインストール

Warning: Failed to create the file

こんなのが出た

mkdir -p ~/.nodebrew/src

でディレクトリーを作ってあげて再度

nodebrew install-binary latest

実行 うまくいった

nodebrew ls

でバージョンの確認
v12.10.0
current: none

none ってのは初期状態のnodeは使用がoffになってるから

nodebrew use v12.10.0

でonにしてあげよう

再度 nodebrew を実行すると

v12.10.0
current: v12.10.0

になった

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

でパスを通して、ターミナルを再起動

rails webpacker:install

を実行すると次は

Yarn not installed. Please download and install Yarn from https://yarnpkg.com/lang/en/docs/install/

だって。。。

あーー イラつく

brew install yarn

を実行

うん
うまくいった

yarnもインストールできたので、再度webpackerをインストール

rails webpacker:install

を実行

結果
Webpacker successfully installed

うまくいった

rails s

を実行

画面が表示された!

よかった

0
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
0
0