質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.35%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

1回答

2851閲覧

ArgumentError: Missing `secret_key_base` for 'production' environmentが解決できない。

AkiDatsugoku26

総合スコア35

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2021/11/08 02:05

前提・実現したいこと

herokuへデプロイしたい。
Rails 6.0.3
ruby 2.6.3
AWS cloud9
ローカルでは問題なく動いています。

試したこと

heroku logsで下記のエラーメッセージが出ています。

(#中略) Bundle complete! 31 Gemfile dependencies, 80 gems now installed. Gems in the groups development and test were not installed. Bundled gems are installed into `./vendor/bundle` Removing bundler (1.17.3) Bundle completed (0.90s) Cleaning up the bundler cache. -----> Installing node-v12.16.2-linux-x64 -----> Installing yarn-v1.22.4 -----> Detecting rake tasks -----> Preparing app for Rails asset pipeline Running: rake assets:precompile yarn install v1.22.4 [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.3.2: The platform "linux" is incompatible with this module. info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning " > @babel/plugin-proposal-private-methods@7.16.0" has unmet peer dependency "@babel/core@^7.0.0-0". warning "@babel/plugin-proposal-private-methods > @babel/helper-create-class-features-plugin@7.16.0" has unmet peer dependency "@babel/core@^7.0.0". warning " > webpack-dev-server@4.4.0" has unmet peer dependency "webpack@^4.37.0 || ^5.0.0". warning "webpack-dev-server > webpack-dev-middleware@5.2.1" has unmet peer dependency "webpack@^4.0.0 || ^5.0.0". [4/4] Building fresh packages... Done in 13.66s. I, [2021-11-08T00:43:08.777049 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/application-55a43ad03dd77c361f6d867fa5670eb8da6801ba309df8603b3d28168792a8ee.css I, [2021-11-08T00:43:08.777522 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/application-55a43ad03dd77c361f6d867fa5670eb8da6801ba309df8603b3d28168792a8ee.css.gz I, [2021-11-08T00:43:08.777967 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/articles-b60f73825b6178fc402d028c659fde87bd48516cc85c63978a7c1e27ce8a1de9.css I, [2021-11-08T00:43:08.780955 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/articles-b60f73825b6178fc402d028c659fde87bd48516cc85c63978a7c1e27ce8a1de9.css.gz I, [2021-11-08T00:43:08.781579 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/static_pages-894b8339632230434a028e3b8f7a798f44ffc97449e4d13bf81f55b9c6b4979e.css I, [2021-11-08T00:43:08.781703 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/static_pages-894b8339632230434a028e3b8f7a798f44ffc97449e4d13bf81f55b9c6b4979e.css.gz I, [2021-11-08T00:43:08.781889 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/users-f2a6914e9b0827cf27fbb86633431bd322d23634d3afd00d29e9d8b77b0414ef.css I, [2021-11-08T00:43:08.782042 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/users-f2a6914e9b0827cf27fbb86633431bd322d23634d3afd00d29e9d8b77b0414ef.css.gz I, [2021-11-08T00:43:08.782224 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/works-572e838ee72d59539333a1f57b8be02cb122782c5c656be072f71a81578fc256.css I, [2021-11-08T00:43:08.782380 #307] INFO -- : Writing /tmp/build_16b63ba0/public/assets/works-572e838ee72d59539333a1f57b8be02cb122782c5c656be072f71a81578fc256.css.gz Compiling… Compilation failed: Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods. The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding ["@babel/plugin-proposal-private-property-in-object", { "loose": true }] to the "plugins" section of your Babel config. ModuleNotFoundError: Module not found: Error: Can't resolve './slick' in '/tmp/build_16b63ba0/app/javascript/packs' (#中略) resolve './slick' in '/tmp/build_16b63ba0/app/javascript/packs' using description file: /tmp/build_16b63ba0/package.json (relative path: ./app/javascript/packs) Field 'browser' doesn't contain a valid alias configuration using description file: /tmp/build_16b63ba0/package.json (relative path: ./app/javascript/packs/slick) no extension Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick doesn't exist .mjs Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.mjs doesn't exist .js Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.js doesn't exist .sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.sass doesn't exist .scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.scss doesn't exist .css Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.css doesn't exist .module.sass Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.module.sass doesn't exist .module.scss Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.module.scss doesn't exist .module.css Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.module.css doesn't exist .png Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.png doesn't exist .svg Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.svg doesn't exist .gif Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.gif doesn't exist .jpeg Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.jpeg doesn't exist .jpg Field 'browser' doesn't contain a valid alias configuration /tmp/build_16b63ba0/app/javascript/packs/slick.jpg doesn't exist as directory /tmp/build_16b63ba0/app/javascript/packs/slick doesn't exist Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods. The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding ["@babel/plugin-proposal-private-property-in-object", { "loose": true }] to the "plugins" section of your Babel config. Though the "loose" option was set to "false" in your @babel/preset-env config, it will not be used for @babel/plugin-proposal-private-property-in-object since the "loose" mode option was set to "true" for @babel/plugin-proposal-private-methods. The "loose" option must be the same for @babel/plugin-proposal-class-properties, @babel/plugin-proposal-private-methods and @babel/plugin-proposal-private-property-in-object (when they are enabled): you can silence this warning by explicitly adding ["@babel/plugin-proposal-private-property-in-object", { "loose": true }] to the "plugins" section of your Babel config. ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app. ! Push failed

"Precompiling assets failed."で調べたところ原因を見つけるために、下記をターミナルで実行してみると、
表題のエラーに突き当たりました。

RAILS_ENV=production bin/rails assets:precompile
ArgumentError: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit`

しかし

EDITOR="vi" bin/rails credentials:edit

を使って既にsecret_key_baseは登録済み、herokuの環境変数にも記載しています。
AWSのアクセスキーとシークレットアクセスキーも一緒に登録済みです。
そこできちんとこれらが登録されているのか確認してみようと思い、

heroku run rails c
irb(main):002:0> Rails.application.credentials.dig(:aws, :access_key_id)

したところ結果は

nil

どうやら登録がうまくいっておらず環境変数の値が読み込まれていないようです。
少し前は問題なくデプロイできたのですが原因が全く分からない状況です。

もしなにか分かる方がいらっしゃいましたらご助言いただけるととても嬉しいです。
ここまで読んで頂きありがとうございました。
よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

ModuleNotFoundError: Module not found: Error: Can't resolve './slick' in '/tmp/build_16b63ba0/app/javascript/packs'

アップロードの実際の原因はこちらに問題があるように思います。
slickの呼び出し部分を確認してみて修正してみてはいかがでしょうか。

投稿2021/11/08 15:42

tetsunosuke

総合スコア1295

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

AkiDatsugoku26

2021/11/09 05:41

ありがとうございます! 無事デプロイできました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.35%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問