TL;DR
-
rails new
する時に--skip-bundle
と--webpack=react
を同時に指定するとエラーになった - 現状は仕様みたい
- newした後でGemfileに
gem 'webpacker'
を追加してbundleした後./bin/rails webpacker:install
すればOK
rails new
したらエラーになった
reactを使った rails
プロジェクトを作ろうと思って rails new
を実行したらエラーになりました。
$ rails new -B --webpack=react sample
create
create README.md
create Rakefile
(中略)
rails webpacker:install
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
rails webpacker:install:react
Could not find gem 'sqlite3' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
考えてみると gem 'webpacker'
がインストールされてないので webpacker:install
出来ないですよね。
解決策
単純ですが new
時に --skip-bundle
したい場合 new
した後で手動でwebpackerを入れればOKです。
$ rails new -B PROJECT_NAME
$ cd PROJECT_NAME
# 以下のコマンド、もしくはエディタでGemfileに追加
$ echo "gem 'webpacker', '~> 2.0'" >> Gemfile
$ bundle install
$ ./bin/rails webpacker:install
# 今回はreactを入れたかったので以下を実行
$ ./bin/rails webpacker:install:react