前提・実現したいこと
Ruby言語を使用し、Railsでtoolサイトを作っています。
Bootstrapのテンプレートをviewファイルに入れた後、Herokuにデプロイしたいのですが、
下記のエラーが発生しました。
ローカル環境ではエラー無く動いております。
発生している問題・エラーメッセージ
console
1(略) 2remote: Compiling... 3remote: Compilation failed: 4remote: ModuleNotFoundError: Module not found: Error: Can't resolve 'popper' in '/tmp/build_d812499c/app/javascript/packs' 5(略) 6remote: resolve 'popper' in '/tmp/build_d812499c/app/javascript/packs' 7remote: Parsed request is a module 8remote: using description file: /tmp/build_d812499c/package.json (relative path: ./app/javascript/packs) 9remote: Field 'browser' doesn't contain a valid alias configuration 10remote: resolve as module 11remote: looking for modules in /tmp/build_d812499c/app/javascript 12remote: using description file: /tmp/build_d812499c/package.json (relative path: ./app/javascript) 13remote: Field 'browser' doesn't contain a valid alias configuration 14remote: using description file: /tmp/build_d812499c/package.json (relative path: ./app/javascript/popper) 15remote: no extension 16remote: Field 'browser' doesn't contain a valid alias configuration 17remote: /tmp/build_d812499c/app/javascript/popper doesn't exist 18(略) 19remote: ! 20remote: ! Precompiling assets failed. 21remote: !
該当のソースコード
Gemfile
1source 'https://rubygems.org' 2git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 4ruby '2.6.5' 5 6# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7gem 'rails', '~> 6.0.0' 8# Use mysql as the database for Active Record 9gem 'mysql2', '>= 0.5.3' 10# Use Puma as the app server 11gem 'puma', '~> 3.11' 12# Use SCSS for stylesheets 13gem 'sass-rails', '~> 5' 14# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker 15gem 'webpacker', '~> 4.0' 16# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 17gem 'turbolinks', '~> 5' 18# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 19gem 'jbuilder', '~> 2.7' 20# Use Redis adapter to run Action Cable in production 21# gem 'redis', '~> 4.0' 22# Use Active Model has_secure_password 23# gem 'bcrypt', '~> 3.1.7' 24 25# Use Active Storage variant 26# gem 'image_processing', '~> 1.2' 27 28# Reduces boot times through caching; required in config/boot.rb 29gem 'bootsnap', '>= 1.4.2', require: false 30 31group :development, :test do 32 # Call 'byebug' anywhere in the code to stop execution and get a debugger console 33 gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 34 35 gem 'pry-rails' 36 gem 'rspec-rails', '~> 4.0.0' 37 gem 'factory_bot_rails' 38end 39 40group :development do 41 # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 42 gem 'web-console', '>= 3.3.0' 43 gem 'listen', '>= 3.0.5', '< 3.2' 44 # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 45 gem 'spring' 46 gem 'spring-watcher-listen', '~> 2.0.0' 47end 48 49group :test do 50 # Adds support for Capybara system testing and selenium driver 51 gem 'capybara', '>= 2.15' 52 gem 'selenium-webdriver' 53 # Easy installation and use of web drivers to run system tests with browsers 54 gem 'webdrivers' 55end 56 57# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 58gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 59 60gem 'bootstrap', '~> 4.3.1' 61gem 'jquery-rails' 62 63gem 'devise'
webpackeryml
1# Note: You must restart bin/webpack-dev-server for changes to take effect 2 3default: &default 4 source_path: app/javascript 5 source_entry_path: packs 6 public_root_path: public 7 public_output_path: packs 8 cache_path: tmp/cache/webpacker 9 check_yarn_integrity: false 10 webpack_compile_output: true 11 12 # Additional paths webpack should lookup modules 13 # ['app/assets', 'engine/foo/app/assets'] 14 resolved_paths: [] 15 16 # Reload manifest.json on all requests so we reload latest compiled packs 17 cache_manifest: false 18 19 # Extract and emit a css file 20 extract_css: false 21 22 static_assets_extensions: 23 - .jpg 24 - .jpeg 25 - .png 26 - .gif 27 - .tiff 28 - .ico 29 - .svg 30 - .eot 31 - .otf 32 - .ttf 33 - .woff 34 - .woff2 35 36 extensions: 37 - .mjs 38 - .js 39 - .sass 40 - .scss 41 - .css 42 - .module.sass 43 - .module.scss 44 - .module.css 45 - .png 46 - .svg 47 - .gif 48 - .jpeg 49 - .jpg 50 51development: 52 <<: *default 53 compile: true 54 55 # Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules 56 check_yarn_integrity: true 57 58 # Reference: https://webpack.js.org/configuration/dev-server/ 59 dev_server: 60 https: false 61 host: localhost 62 port: 3035 63 public: localhost:3035 64 hmr: false 65 # Inline should be set to true if using HMR 66 inline: true 67 overlay: true 68 compress: true 69 disable_host_check: true 70 use_local_ip: false 71 quiet: false 72 pretty: false 73 headers: 74 'Access-Control-Allow-Origin': '*' 75 watch_options: 76 ignored: '**/node_modules/**' 77 78 79test: 80 <<: *default 81 compile: true 82 83 # Compile test packs to a separate directory 84 public_output_path: packs-test 85 86production: 87 <<: *default 88 89 # Production depends on precompilation of packs prior to booting for performance. 90 compile: false 91 92 # Extract and emit a css file 93 extract_css: true 94 95 # Cache manifest.json for performance 96 cache_manifest: true
databaseyml
1# MySQL. Versions 5.5.8 and up are supported. 2# 3# Install the MySQL driver 4# gem install mysql2 5# 6# Ensure the MySQL gem is defined in your Gemfile 7# gem 'mysql2' 8# 9# And be sure to use new-style password hashing: 10# https://dev.mysql.com/doc/refman/5.7/en/password-hashing.html 11# 12default: &default 13 adapter: mysql2 14 encoding: utf8 15 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 16 username: root 17 password: 18 socket: /tmp/mysql.sock 19 20development: 21 <<: *default 22 database: jr_tool_development 23 24# Warning: The database defined as "test" will be erased and 25# re-generated from your development database when you run "rake". 26# Do not set this db to the same as development or production. 27test: 28 <<: *default 29 database: jr_tool_test 30 31# As with config/credentials.yml, you never want to store sensitive information, 32# like your database password, in your source code. If your source code is 33# ever seen by anyone, they now have access to your database. 34# 35# Instead, provide the password as a unix environment variable when you boot 36# the app. Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 37# for a full rundown on how to provide these environment variables in a 38# production deployment. 39# 40# On Heroku and other platform providers, you may have a full connection URL 41# available as an environment variable. For example: 42# 43# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase" 44# 45# You can use this database configuration with: 46# 47# production: 48# url: <%= ENV['DATABASE_URL'] %> 49# 50production: 51 <<: *default 52 database: jr_tool_production 53 username: jr_tool 54 password: <%= ENV['JR_TOOL_DATABASE_PASSWORD'] %>
packagejson
1{ 2 "name": "jr_tool", 3 "private": true, 4 "dependencies": { 5 "@rails/actioncable": "^6.0.0-alpha", 6 "@rails/activestorage": "^6.0.0-alpha", 7 "@rails/ujs": "^6.0.0-alpha", 8 "@rails/webpacker": "4.3.0", 9 "bootstrap": "^4.5.3", 10 "jquery": "^3.5.1", 11 "popper.js": "^1.16.1", 12 "turbolinks": "^5.2.0" 13 }, 14 "version": "0.1.0", 15 "devDependencies": { 16 "webpack-dev-server": "^3.11.0" 17 } 18}
applicationjs
1// This file is automatically compiled by Webpack, along with any other files 2// present in this directory. You're encouraged to place your actual application logic in 3// a relevant structure within app/javascript and only use these pack files to reference 4// that code so it'll be compiled. 5require ("./jquery3") 6require ("popper") 7require ("bootstrap") 8 9 10require("@rails/ujs").start() 11require("turbolinks").start() 12require("@rails/activestorage").start() 13require("channels") 14 15 16// Uncomment to copy all static images under ../images to the output folder and reference 17// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) 18// or the `imagePath` JavaScript helper below. 19// 20// const images = require.context('../images', true) 21// const imagePath = (name) => images(name, true)
試したこと
https://teratail.com/questions/252386
こちらの方が似たような状況でしたので”yarn add jquery bootstrap popper.js”を実行してみましたが、同じエラーが出ます。
このエラーが出る前にjquery3でも同様のエラーが出てました、その際はapplication.jsのrequire ("jquery3")を=>require ("./jquery3")
にした事で解決したので、popperも同じ様にしてみましたが変わらないので戻してあります。
補足情報(FW/ツールのバージョンなど)
Macbook
Ruby on Rails 6.0.0
Bootstrap 4.3.1
あなたの回答
tips
プレビュー