前提
$ rails -v
Rails 6.0.3
$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin21]
起きたこと1
Webpacker::Manifest::MissingEntryError
$ bin/rails s
<略>
ActionView::Template::Error (Webpacker can't find application in /Users/kosuke/works/rails-demo/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:
{
}
):
6: <%= csp_meta_tag %>
7:
8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
10: </head>
11:
12: <body>
起きたこと2
webpacker:compile ができない。
$ bin/rails webpacker:compile
Compiling...
Compilation failed:
node:internal/crypto/hash:71
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:71:19)
at Object.createHash (node:crypto:133:10)
試したこと
- webpackerのバージョンを上げる
- node のバージョンを下げる
# gem 'webpacker', '~> 4.0'
gem 'webpacker', '~> 5.0'
$ bundle
$ bin/rails webpacker:install
$ node -v
v18.7.0
$ nodenv local 14.16.1
$ node -v
v14.16.1
$ bin/rails s
参考
感想
- 手元のnodeが v18.7.0だったから webpakcerと相性が悪かった。
- webpackerを、 '~> 4.0' から '~> 5.0' にすればいいらしい。