概要
-
webpacker:install:react
orwebpacker:install:react
がWebpack binstubs not found.
で失敗したときの暫定対処方法 - エラーの原因は
webpack
とwebpack-dev-server
インストールされていないこと - 応急措置として、該当ファイルをwebpackerのソースからダウンロードして、適切な場所にコピーして、再度実行したら解決できた
環境
- Docker: Version 17.09.0-ce-mac35 (19611)
- ruby: 2.4.2 (2.4.1でも同様の状況を確認)
- rails: 5.1.4
- node: 8, (6, 7, 9でも同様の状況を確認)
- webpacker: 3.0.2
- mac: 10.13.1
詳細
事前内容
-
Dockerでwebpacker 3.0 が動かない時にやったことを参考にdockerをbuildしていたところ
rails webpacker:install:react
で最終的に下記のエラーが発生。 - 結果、vue(react)のインストールに失敗した
エラーログ抜粋
Installing binstubs
run bundle binstubs webpacker from "."
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
省略
Done in 44.63s.
Webpacker successfully installed 🎉 🍰
rails webpacker:install:react
Webpack binstubs not found.
Have you run rails webpacker:install ?
Make sure the bin directory or binstubs are not included in .gitignore
Exiting!
run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
原因
ログを見ると原因は、webpack
とwebpack-dev-server
がbin/
にコピーされていないことだとわかった。
対処法
-
ファイルが足りないのが原因なので、webpackerのマスターから
webpack
とwebpack-dev-server
をダウンロードしてbin/
にコピーし、再度webpacker:install:react
を実行したら解決した。 -
なお、ログで勧められている
bundle binstubs webpacker --force
をしてもうまくいきませんでした。
その他
- 数ヶ月前は特に問題なかったので、webpackerのバージョンの原因かも
- docker以外でエラーが発生するかどうかは試していない。