Compilation failed: remote: ModuleNotFoundError: Module not found: Error When pushing to Heroku

Viewed 399

I am trying to push an RoR web app to Heroku, but I am getting the following build error:

remote:        Compilation failed:
remote:        ModuleNotFoundError: Module not found: Error: Can't resolve '../stylesheets/application' in '/tmp/build_7e435f25/app/javascript/packs'
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/Compilation.js:925:10
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:401:22
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:130:21
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:224:22
remote:            at /tmp/build_7e435f25/node_modules/neo-async/async.js:2830:7
remote:            at /tmp/build_7e435f25/node_modules/neo-async/async.js:6877:13
remote:            at /tmp/build_7e435f25/node_modules/webpack/lib/NormalModuleFactory.js:214:25
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:213:14
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:44:7
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/RootPlugin.js:37:38
remote:            at _next42 (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:31:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/Resolver.js:285:5
remote:            at eval (eval at create (/tmp/build_7e435f25/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:27:15
remote:            at /tmp/build_7e435f25/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:85:15
remote:        resolve '../stylesheets/application' in '/tmp/build_7e435f25/app/javascript/packs'
remote:          using description file: /tmp/build_7e435f25/package.json (relative path: ./app/javascript/packs)
remote:            Field 'browser' doesn't contain a valid alias configuration
remote:            using description file: /tmp/build_7e435f25/package.json (relative path: ./app/javascript/stylesheets/application)
remote:              no extension
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application doesn't exist
remote:              .mjs
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.mjs doesn't exist
remote:              .js
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.js doesn't exist
remote:              .sass
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.sass doesn't exist
remote:              .scss
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.scss doesn't exist
remote:              .css
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.css doesn't exist
remote:              .module.sass
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.sass doesn't exist
remote:              .module.scss
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.scss doesn't exist
remote:              .module.css
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.module.css doesn't exist
remote:              .png
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.png doesn't exist
remote:              .svg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.svg doesn't exist
remote:              .gif
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.gif doesn't exist
remote:              .jpeg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.jpeg doesn't exist
remote:              .jpg
remote:                Field 'browser' doesn't contain a valid alias configuration
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application.jpg doesn't exist
remote:              as directory
remote:                /tmp/build_7e435f25/app/javascript/stylesheets/application doesn't exist
remote:        
remote: 
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 6cb1ee551129b46d6adf70c5e8e9788d0c8605f5
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 6cb1ee551129b46d6adf70c5e8e9788d0c8605f5
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to bee-arquitetura.
remote: 

I have tried looking at the bootstrap Sass documentation [Bootstrap Sass Webpack doc][1]

I originally had a Sass error which I was able to work through but I am not able to figure out what might be causing this error.

2 Answers

try to edit 'application.js' in the path 'app/javascript/packs/application.js' to:

import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"

Rails.start()
Turbolinks.start()
ActiveStorage.start()

import 'bootstrap/dist/js/bootstrap'
import 'bootstrap/dist/css/bootstrap'
require("stylesheets/application.scss")

I think you have to rename you "application" file (path: app/assets/stylesheets) and add an extension like ".css"

actual name: "application"

modified name: "application.css"

(path: app/assets/stylesheets)

rename your application file

Related