前提・実現したいこと
Rails 5.1で作成したwebアプリをherokuにデプロイしたい。
Railsチュートリアルを参考に進めてきましたが、デプロイの段階でエラーが発生し、yarnやnodeをダウンロードしろと言われ実行。
その後も後述の試したことを実行し、デプロイを試し続けていると以下のエラーメッセージが発生。
おそらく原因は書いてある通りapplication.jsのNoMethodErrorだとは思うのですが、自身で書いたところに思い当たる場所はない。
全く見当違いなのかどうなのかもわからない状況です。
もし解決策がわかる方がいらっしゃいましたら教えていただきたいです。
発生している問題・エラーメッセージ
エラーメッセージ ・ ・ ・ remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: yarn install v1.5.1 remote: remote: info No lockfile found. remote: remote: [1/5] Validating package.json... remote: remote: [2/5] Resolving packages... remote: remote: [3/5] Fetching packages... remote: remote: [4/5] Linking dependencies... remote: remote: [5/5] Building fresh packages... remote: remote: info Lockfile not saved, no dependencies. remote: remote: Done in 0.08s. remote: remote: I, [2018-04-02T07:54:42.087276 #1462] INFO -- : Writing /tmp/build_d143afa130a0f73d37ef2131d4688446/public/assets/application-c6dfdd4d1c5e54c6df669b033436b08bed94a7943fd9207542e7b5c64998d5d7.js remote: remote: I, [2018-04-02T07:54:42.088046 #1462] INFO -- : Writing /tmp/build_d143afa130a0f73d37ef2131d4688446/public/assets/application-c6dfdd4d1c5e54c6df669b033436b08bed94a7943fd9207542e7b5c64998d5d7.js.gz remote: remote: rake aborted! remote: remote: NoMethodError: undefined method `[]' for nil:NilClass remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/sass_processor.rb:278:in `sprockets_context' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/sass_processor.rb:124:in `asset_path' ・ ・#文字制限のため省略 ・ remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:185:in `compile' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:68:in `block (3 levels) in define' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:147:in `with_logger' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in define' remote: remote: /tmp/build_f93f2039b4d4fa17656aa8ba68ac7fe9/vendor/bundle/ruby/2.4.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>' remote: remote: Tasks: TOP => assets:precompile remote: remote: (See full trace by running task with --trace) remote: remote: ! remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to warm-earth-28275. remote: To https://git.heroku.com/warm-earth-28275.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/warm-earth-28275.git'
#application.js // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's // vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. JavaScript code in this file should be added after the last require_* statement. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require rails-ujs //= require turbolinks //= require_tree . $(document).ready(function(){ $(window).load(function(){ window.setTimeout("$('#alertfadeout').fadeOut()", 2000); }); });
試したこと
yarnのダウンロード+インストール
node.jsのダウンロード+インストール
#コマンドプロンプト $heroku buildpacks:add --index 1 heroku/nodejs $heroku buildpacks:add --index 2 heroku/ruby
の実行
#package.json "engines": { "yarn": "バージョン", "node": "バージョン" }
の追加
補足情報(FW/ツールのバージョンなど)
#gemfile source 'https://rubygems.org' ruby '2.4.3' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.5' # Use Puma as the app server gem 'puma', '~> 3.7' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use CoffeeScript for .coffee assets and views gem 'coffee-rails', '~> 4.2' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.5' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development group :development, :test do # Use sqlite3 as the database for Active Record gem 'sqlite3' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] # Adds support for Capybara system testing and selenium driver gem 'capybara', '~> 2.13' gem 'selenium-webdriver' end group :development do # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' end group :production do gem 'pg' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'coffee-script-source', '1.8.0' gem 'bootstrap-sass', '3.2.0.0' gem "jquery-rails"
回答2件
あなたの回答
tips
プレビュー